- Impact
- 8
This is driving me crazy.
My code below displays 3 records, sometimes 1 record, while there are 5 matching records! I did output the $num and it was 5, but not all the 5 records are displayed. Help please. Code below:
---------- Post added at 12:16 AM ---------- Previous post was at 12:01 AM ----------
OMG, I got it; I was missing a single quote
Thanks everyone
My code below displays 3 records, sometimes 1 record, while there are 5 matching records! I did output the $num and it was 5, but not all the 5 records are displayed. Help please. Code below:
Code:
<ul>
<?php
include("siteconfig.php");
// connect to server and select databse
$conn = mysql_connect("$host", "$username", "$password") or die("cannot connect!");
mysql_select_db("$db_name")or die("cannot select database!");
// execute sql
$sql = "select * from pages where parentid = 0 and online = 1";
$result = mysql_query($sql) or die('error, insert query failed');
// close connection
mysql_close($conn);
// get number of records
$num = mysql_numrows($result);
$i=0;
if($num > 0)
{
while ($i < $num)
{
echo "<li><a href='page.php?pid=".mysql_result($result,$i,"pid").">".mysql_result($result,$i,"title")."</a></li>";
$i++;
}
}
?>
</ul>
---------- Post added at 12:16 AM ---------- Previous post was at 12:01 AM ----------
OMG, I got it; I was missing a single quote