Log in

View Full Version : Not Showing All Results



Titan85
08-20-2007, 02:55 PM
I have a script that is simply supposed to show all links in the database. For some reason, it does not show the newest link in the table. Here is my code:
<?php

$level = $_SESSION['level'];

########## If No Action ##########
if (!$_GET['act'] && !$_POST['delete']) {
if ($level < 1) { die('<meta http-equiv="refresh" content="2;URL=index.php" /> <div class="error">You do not have permission to access this page</div>'); } else {
$get = mysql_query("SELECT * FROM `links` ORDER BY id DESC") or die ("Error Getting Users! \n<br />\n" .mysql_error());
$u = mysql_fetch_array($get);
$chk = mysql_num_rows($get);

// If No Resuts
if ($chk < 1) { echo('No links at this time.'); } else { $count = 1; $color = $col1; ?>

<b>Navigation:</b> <a href="add.php">Add New Link</a> <br />
<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
<table width="500" align="center" class="admin_table">
<tr bgcolor="<?php echo $col3 ?>">
<td>ID</td>
<td>Title</td>
<td>URL</td>
<td>View Level</td>
<td>Edit</td>
<td>Delete</td>
</tr>
<?php while ($u = mysql_fetch_array($get)) { $l = parse_url($u['url']); ?>
<tr bgcolor="<?php echo $color ?>">
<td><?php echo $u['id'] ?></td>
<td><?php echo $u['title'] ?></a></td>
<td><a href="<?php echo $u['url'] ?>" target="_blank"><?php echo $l[path] ?></a></td>
<td><?php echo $u['viewLvl'] ?></td>
<td><a href="?act=edit&amp;id=<?php echo $u['id'] ?>"><img src="../../images/edit.png" alt="Edit" border="0" /></a></td>
<td><input type="checkbox" name="checkbox[]" value="<?php echo $u['id'] ?>" /></td>
</tr>
<?php ++$count; if ($color == $col1) { $color = $col2; } else {$color = $col1; }
} ?>
</table>
</form>

<?php
}
}
}
?>
I don't see anything that should cause this. Anyone know what is going wrong? Thanks

tech_support
08-21-2007, 10:15 AM
$count = 1; should be $count = 0;

Titan85
08-21-2007, 12:22 PM
$count = 1; should be $count = 0;That doesn't seem to be the problem. That code is for the row colors and not for the results display. I did try changing it to 0 and got no change. Any other ideas?

I found that when I add a pagination script and limit 1 result to each page, it will not show any results on a page, but it will have a page link for the correct amount of results.