I've run into a problem with php, I have this table:
<?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>
But I'm looking for this output:
How can I improve my code so I can get this result?
$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>";
This may help you
<?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>