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?

Link to comment
Share on other sites

<?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>";
}
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.