如何将SQL数据库信息输入到php表中

时间:2017-11-28 15:27:17

标签: php html mysql sql database

我输入的数据库信息包括团队徽标和相应的团队名称。 尽管各种谷歌搜索和论坛搜索,我找不到解决方案。 任何帮助将不胜感激。

<!DOCTYPE html>
<html>
<body>

<?php
  $connection = mysqli_connect("localhost","root","");
  mysqli_select_db($connection,"6nationsDB");
  $result=mysqli_query($connection,"select * from teams");
$counter = 1;
  while($row=mysqli_fetch_array($result))
  {
    $image="images/$counter.png";
    print"<img src=\"$image\" width=\"15px\" height=\"15px\"\/>";
    print($row['name']);

    print("<br>");


    $counter++;
  }

  $rows = 10; // amout of tr 
$cols = 10;// amjount of td 
function drawTable($rows, $cols){
echo "<table border='1'>"; 

for($tr=1;$tr<=$rows;$tr++){ 

    echo "<tr>"; 
        for($td=1;$td<=$cols;$td++){ 
               echo "<td align='center'>".'<img src=\"$image\" width=\"15px\" height=\"15px\"\/>'."</td>"; 

        }

    echo "</tr>"; 
} 
echo "</table>";

}
drawTable(6, 2);
  mysqli_close($connection);
?>
</body>
</html>

0 个答案:

没有答案