在表中插入数据但未链接的whit表

时间:2017-07-20 11:06:31

标签: php mysql

我想要做的是在我的专栏中插入数据"得分"但不是从我的phpmyadmin表中没有包含的行。

实际上这个数据是前一个5列的附加内容,而且我添加了一个查询mysql。

这是我的表:

enter image description here

这是我的代码:

<?php
    // Include config file
    require_once 'configgate.php';
$bdd=new PDO('mysql:host=localhost;dbname=cmadatabase','root','@Rugby3390');
$bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$reponse= $bdd->query('SELECT `ID`,`Level`,`Typ`,`Occurrence`,`Supplier`,`Consequences`,
                                SUM((/*0.5**/`Level`)+/*0.5**/`Typ`+/*0.5**/`Occurrence`+/*0.5**/`Supplier`+/*0.5**/`Consequences`) AS sommeLTOSC 
                        FROM `andgate` 
                        GROUP BY `ID`,`Level`,`Typ`,`Occurrence`,`Supplier`,`Consequences` 
                        ORDER BY sommeLTOSC  DESC');
while ($donnees = $reponse->fetch()){

    //echo $donnees['sommeLTOSC'].'<p>';
}
                // Attempt select query execution
                $sql = "SELECT * FROM andgate";
                if($result = $mysqli->query($sql)){
                    if($result->num_rows > 0){
                        echo "<table class='table table-bordered table-striped'>";
                            echo "<thead>";
                                echo "<tr>";
                                    echo "<th>ID</th>";
                                    echo "<th>IR</th>";
                                    echo "<th>Level</th>";
                                    echo "<th>Type</th>";
                                    echo "<th>Occurrence</th>";
                                    echo "<th>Supplier</th>";
                                    echo "<th>Consequences</th>";
                                    echo "<th>Candidate TBA</th>";
                                    echo "<th>Engineer Judgment</th>";
                                    echo "<th>Remarks</th>";
                                    echo "<th>Score</th>";
                                echo "</tr>";
                            echo "</thead>";
                            echo "<tbody>";
                            while($row = $result->fetch_array()){
                                echo "<tr>";
                                    echo "<td>" . $row['ID'] . "</td>";
                                    echo "<td>" . $row['IR'] . "</td>";
                                    echo "<td>" . $row['Level'] . "</td>";
                                    echo "<td>" . $row['Typ'] . "</td>";
                                    echo "<td>" . $row['Occurrence'] . "</td>";
                                    echo "<td>" . $row['Supplier'] . "</td>";
                                    echo "<td>" . $row['Consequences'] . "</td>";
                                    echo "<td>" . $row['Candidate'] . "</td>";
                                    echo "<td>" . $row['Engineer'] . "</td>";
                                    echo "<td>" . $row['Remarks'] . "</td>";
                                    echo "<td>" . $donnees['sommeLTOSC'] . "</td>";

我的问题是最后回声,我无法访问数据,你能帮帮我吗? 非常感谢

以下是我修改的代码:

 <?php
                    // Include config file
                   require_once 'configgate.php';


    $reponse= $mysqli->query("SELECT `ID`,`Level`,`Typ`,`Occurrence`,`Supplier`,`Consequences`,
                                    SUM((/*0.5**/`Level`)+/*0.5**/`Typ`+/*0.5**/`Occurrence`+/*0.5**/`Supplier`+/*0.5**/`Consequences`) AS sommeLTOSC 
                            FROM `andgate` 
                            GROUP BY `ID`,`Level`,`Typ`,`Occurrence`,`Supplier`,`Consequences` 
                            ORDER BY sommeLTOSC  DESC");
    while ($row = $reponse->fetch())





                    // Attempt select query execution
                    $sql = "SELECT * FROM andgate";
                    if($result = $mysqli->query($sql)){
                        if($result->num_rows > 0){
                            echo "<table class='table table-bordered table-striped'>";
                                echo "<thead>";
                                    echo "<tr>";
                                        echo "<th>ID</th>";
                                        echo "<th>IR</th>";
                                        echo "<th>Level</th>";
                                        echo "<th>Type</th>";
                                        echo "<th>Occurrence</th>";
                                        echo "<th>Supplier</th>";
                                        echo "<th>Consequences</th>";
                                        echo "<th>Candidate TBA</th>";
                                        echo "<th>Engineer Judgment</th>";
                                        echo "<th>Remarks</th>";
                                        echo "<th>Score</th>";
                                    echo "</tr>";
                                echo "</thead>";
                                echo "<tbody>";
                                while($row = $result->fetch_array()){
                                    echo "<tr>";
                                        echo "<td>" . $row['ID'] . "</td>";
                                        echo "<td>" . $row['IR'] . "</td>";
                                        echo "<td>" . $row['Level'] . "</td>";
                                        echo "<td>" . $row['Typ'] . "</td>";
                                        echo "<td>" . $row['Occurrence'] . "</td>";
                                        echo "<td>" . $row['Supplier'] . "</td>";
                                        echo "<td>" . $row['Consequences'] . "</td>";
                                        echo "<td>" . $row['Candidate'] . "</td>";
                                        echo "<td>" . $row['Engineer'] . "</td>";
                                        echo "<td>" . $row['Remarks'] . "</td>";
                                        echo "<td>" . $row['sommeLTOSC'] . "</td>";

这是我的错误:致命错误:在第49行的C:\ wamp64 \ www \&amp; Gate \ indexgate.php中调用未定义的方法mysqli_result :: fetch()

THX

0 个答案:

没有答案