HTML table using MySQLi and PHP

后端 未结 2 651
伪装坚强ぢ
伪装坚强ぢ 2020-11-28 16:40

I\'m trying to make a table connected to my database so I can use the information in that database.

I think I\'m on the right way, but currently the table only displ

相关标签:
2条回答
  • 2020-11-28 17:34

    Perhaps this is because you have not opened your HTML table tags correctly, its an easy thing to overlook. Also loop the result set inside a white statement:

    $sql = "SELECT `name`,`date`,`present`,`website` FROM `dates`";
    $results = mysqli_query($conn,$sql);
    echo "<table>"; //begin table tag...
    //you can add thead tag here if you want your table to have column headers
     while($rowitem = mysqli_fetch_array($results)) {
        echo "<tr>";
        echo "<td>" . $rowitem['name'] . "</td>";
        echo "<td>" . $rowitem['date'] . "</td>";
        echo "<td>" . $rowitem['present'] . "</td>";
        echo "<td>" . $rowitem['website'] . "</td>";*/
        echo "</tr>";
    }
    echo "</table>"; //end table tag
    
    0 讨论(0)
  • 2020-11-28 17:42

    Your code gets only one row from table, you need loop your results.
    Try this code:

    $results = mysqli_query($conn,$sql);
    
    while($row = mysqli_fetch_array($results))
    {
      //do smth
    }
    
    0 讨论(0)
提交回复
热议问题