Jump to content

[SOLVED] While statement showing duplicates


daveh33

Recommended Posts

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$id = $row['id'];
$name = $row['name'];
$lup = $row['lastupdate'];
$tb = $row['tablename'];
$lastupdated = date("jS F Y H:i",strtotime($lup));
if ($tb) {
$result = mysql_query("SELECT * from $tb");
$num = mysql_num_rows($result);
}
echo "	 </tr><tr><td><p align=\"center\">$id</td>
<td><p align=\"center\">$name</td>
<td><p align=\"center\"><a href=\"managenumbers.php?id=$id\">$num</a></td>
<td><p align=\"center\">$lastupdated</td>
<td><p align=\"center\"><a href=\"edit.php?function=list&id=$id\"><img src=\"edit.gif\" border=\"0\"></a></td>
<td><p align=\"center\"><a href=\"delete.php?function=list&id=$id\"><img src=\"delete.gif\" border=\"0\"></a></td>";
}

 

I have the above code, there is 1 row in my table and $num=4

 

Instead of it just showing 1 row - it shows 4... any ideas why? Guess its something to do with the numrows during the while statement?

<?php
while($row = mysql_fetch_assoc($result)) {
$id = $row['id'];
$name = $row['name'];
$lup = $row['lastupdate'];
$tb = $row['tablename'];
$lastupdated = date("jS F Y H:i",strtotime($lup));
if (isset($tb)) {
$result = mysql_query("SELECT * from $tb");
$num = mysql_num_array($result);
echo "	 </tr><tr><td><p align=\"center\">$id</td>
<td><p align=\"center\">$name</td>
<td><p align=\"center\"><a href=\"managenumbers.php?id=$id\">$num</a></td>
<td><p align=\"center\">$lastupdated</td>
<td><p align=\"center\"><a href=\"edit.php?function=list&id=$id\"><img src=\"edit.gif\" border=\"0\"></a></td>
<td><p align=\"center\"><a href=\"delete.php?function=list&id=$id\"><img src=\"delete.gif\" border=\"0\"></a></td>";
}
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.