php,如果我连接第二个sql表,第一个的东西消失

时间:2015-09-11 10:26:46

标签: php html mysql sql

所以我有一个问题,它只显示第二个sql表的“personen”。 而第一个也没有数据。

<table border="1" class="table">
                    <tr>
                        <th class="tabl">Id</th>
                        <th class="tabl">Naam</th>
                        <th class="tabl">Adres</th>
                        <th class="tabl">Telefoonnummer</th>
                        <th class="tabl">Email</th> 
                        <th class="tabl">Linkedin</th>
                        <th class="tabl">Facebook</th>
                        <th class="tabl">Twitter</th>
                        <th class="tabl">Eigen website</th>
                        <th class="tabl">Branchering</th>
                        <th class="tabl">Personen</th> 
                        <th class="tabl">links</th>
                        <th class="tabl">opdrachten</th>
                        <th class="tabl">info</th> 
                        <th class="tabl">foto's</th> 
                    </tr>
                    <?php
                        $link = @mysqli_connect("localhost", "root", "", "citylab"); 
                        if (!$link) 
                        {
                            die("Connection failed: " . mysqli_connect_error());
                        }

                        if($gamesres === FALSE)
                        {
                                echo mysqli_error($link);
                        }
                        $gamesquery = "SELECT * FROM bedrijf;"; 
                        $gamesres = mysqli_query($link, $gamesquery);
                        $gamen = $row["gamen"];
                        if (mysqli_num_rows($gamesres) > 0) 
                        {
                            while($gamesrow = mysqli_fetch_assoc($gamesres)) {
                                echo "<tr>";
                                echo "<td class='tabl'>" . $row["id"] . "</td>"; 
                                echo "<td class='tabl'>" . $row["naam"] . "</td>";
                                echo "<td class='tabl'>" . $row["adres"] . "</td>";
                                echo "<td class='tabl'>" . $row["telnr"] . "</td>";
                                echo "<td class='tabl'>" . $row["email"] . "</td>";
                                echo "<td class='tabl'><a href='" . $row["linkedin"] . "' target='_Blank'>Link</a></td>";
                                echo "<td class='tabl'><a href='" . $row["fb"] . "' target='_Blank'>Link</a></td>";
                                echo "<td class='tabl'><a href='" . $row["twitter"] . "' target='_Blank'>Link</a></td>";
                                echo "<td class='tabl'><a href='" . $row["eigensite"] . "' target='_Blank'>Link</a></td>";
                                echo "<td class='tabl'>" . $row["branchering"] . "</td>";
                                $personenquery = "SELECT * FROM personen WHERE bedrijfid =".$gamesrow["id"]." ;";
                                $personenres = mysqli_query($link, $personenquery);

                                if($personenres === FALSE)
                                {
                                    echo mysqli_error($link);
                                }
                                if (mysqli_num_rows($personenres) > 0) 
                                {
                                    while($row = mysqli_fetch_assoc($personenres)) 
                                    {
                                        echo "<td class='tabl'>" . $row["naam"] . "</td>";
                                    }
                                }
                                echo "</tr>";
                            }
                        }
                    ?>
                </table>

有代码,我想我在这里做错了什么:

$gamesquery = "SELECT * FROM bedrijf;"; 
                    $gamesres = mysqli_query($link, $gamesquery);
                    $gamen = $row["gamen"];
                    if (mysqli_num_rows($gamesres) > 0) 
                    {
                        while($gamesrow = mysqli_fetch_assoc($gamesres)) {
提前谢谢,我真的希望有人可以帮助我。

0 个答案:

没有答案