Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用PHP生成HTML表_Php_Html_Css - Fatal编程技术网

用PHP生成HTML表

用PHP生成HTML表,php,html,css,Php,Html,Css,我遇到了php问题,我有以下表格: <?php $s=(" SELECT * FROM my_tbl"); $W=mysql_query($s); ?> <table> <tr> <td> <center><strong>Member </strong></center></td> </tr><t

我遇到了php问题,我有以下表格:

    <?php 
     $s=(" SELECT * FROM my_tbl");
     $W=mysql_query($s); 
     ?> 
     <table>
     <tr>
     <td> <center><strong>Member </strong></center></td> 
</tr><tr>
     <td> <center><strong> Total Meal </strong></center></td> 
     </tr> 
     <?php while ( $r=mysql_fetch_array($W)) {$i++; ?>
     <tr > <td> <?= $r["name"]; ?> </td></tr>
<tr>
     <td> <?= $r["tmeal"]; ?> </td>
     </tr><?php } ?>
     </table>

成员
总膳食量
但我正在寻找这个输出:

如何改进代码以获得此结果?

$conn=mysqli_connect('server'、'username'、'password'、'DB NAme')或die(“error”);
 $conn = mysqli_connect('server','username','password',"DB NAme") or die("error");

 $queryString = "select * from TableNAme";
 $queryres    = mysqli_query($conn, $queryString) or die("not fire");

 echo "<table>";
 while($row = mysqli_fetch_array($queryres))
 {
   echo "<tr><td>$row[0]</td><td>$row[0]</td><td>$row[0]</td></tr>";
 }
 echo "</table>";
$queryString=“从表名中选择*”; $queryres=mysqli_query($conn,$queryString)或die(“非火灾”); 回声“; while($row=mysqli\u fetch\u数组($queryres)) { 回显“$row[0]$row[0]$row[0]”; } 回声“; 这可能会对您有所帮助

 <?php
  $con = mysql_connect("localhost", "root", "mypass") or  
      die("Could not connect: " . mysql_error());  
  mysql_select_db("your_db"); 
  $s=(" SELECT * FROM my_tbl");
  $W=mysql_query($s); ?>
  <table>
  <tr>
  <td> <center><strong>Member </strong></center></td> 
  <td> <center><strong> Total Meal </strong></center></td> 
  </tr> 
  <?php while ( $r = mysql_fetch_assoc($W)) { ?>
  <tr > <td> <? php echo $r['name']; ?></td> 
  <td> <? php echo $r['tmeal']; ?>  </td> 
   </tr><?php   } ?>
  </table>

成员
总膳食量

这些数据是否来自数据库?请展示您所做的尝试。是的,这些数据来自数据库。。对象操纵器您目前的代码是什么是Yes,同意@RemyaR您到目前为止尝试了什么?您的html和php代码在哪里?mysql扩展已被弃用,将来将被删除,请使用mysqli或PDO代替mysqli是的,先生,我同意您的意见,Devs先生