<?php
$sql = "SELECT * FROM info where ip='$ip2' LIMIT 5";
$result = $conn->query($sql);
while($row = $result->fetch_assoc()) {
?>
<table id="keywords" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th><span>URL</span></th>
<th><span>Created Date</span></th>
<th><span>Short </span></th>
</tr>
</thead>
<tbody>
<tr>
<td class="lalign"><?php echo $row["url"];?></td>
<td><?php echo $row["short"];?></td>
<td><?php echo $row["date"];?></td>
<td>1</td>
</tr>
</tbody><?php }?>
</table>
echo table with while loop
Page 1 of 13 Replies - 1799 Views - Last Post: 19 February 2017 - 10:53 AM
#1
echo table with while loop
Posted 19 February 2017 - 08:55 AM
I'm trying to loop through a database and output data into table but not working any advise
Replies To: echo table with while loop
#2
Re: echo table with while loop
Posted 19 February 2017 - 08:59 AM
Are you sure you are even getting rows back?
#3
Re: echo table with while loop
Posted 19 February 2017 - 09:14 AM
Deprecated MySQL functions are simpler to use (not counting all the sanitizing you need to add) than PDO or MySQLi prepared statements, but far less secure. That's why they've been deprecated. If you're just learning PHP you should start with
http://www.dreaminco...duction-to-pdo/
or
http://php.net/manua...-statements.php
When dealing with old code that uses deprecated MySQL functions you should replace them if possible. If it's not possible, your experience with PDO or MySQLi will benefit you when dealing with MySQL functions.
http://www.dreaminco...duction-to-pdo/
or
http://php.net/manua...-statements.php
When dealing with old code that uses deprecated MySQL functions you should replace them if possible. If it's not possible, your experience with PDO or MySQLi will benefit you when dealing with MySQL functions.
#4
Re: echo table with while loop
Posted 19 February 2017 - 10:53 AM
(Why are you attempting to repeat the whole table per row? But, even then, you are omitting the closing table tag each time, until the last table. Presumably, you should only be repeating the rows.)
Page 1 of 1

New Topic/Question
Reply



MultiQuote







|