Hi everybody,
I am having a problem running this script. It gives an error inside the function "display_records() at the sql query".
+++++++++++ SCRIPT BEGINS ++++++++++++++++++
//multiple Results from a Database file project
<?
$limit=10;
function display_records($start,$end)//Generic function to display records
{
$conid=mysql_connect("localhost","USERNAME","PWD");
mysql_select_db("mydb",$conid)
//$sql="select from theworld limit $start,$end";
$query=mysql_query("select from theworld limit $start,$end",$conid);
echo "<table border=1>";
while($results=mysql_fetch_array($query))
{
prinf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>",$results["id"],$results["first"],$results["last"],$results["email"],$results["phone"],$results["address"],$results["sex"],$results["profession"]);
}
echo "</table>";
}
if(!$offset)
{
$offset=0;//The first time results are pulled out
}
$conid=mysql_connect("localhost","root","morfeus");
mysql_select_db("mydb",$conid);
$sql="select * from theworld";
$query=mysql_query($sql,$conid);
if(mysql_num_rows($query)<10)
{
//Do nothing and display the results as they are.
$start=$offset;
$end=10;
display_records($start,$end);
}
else//Print those many page numbers and pages to display
{
$no_of_pages=(mysql_num_rows($query)/$limit);
if(is_real($no_of_pages))
{
$no_of_pages++;//If we have something more than the exact dicision i.e. a remainder, then
// add up an extra page. It's free and doesn't cost you nothing!
}
printf("<b>No of pages for your results are:%s</b><br>",$no_of_pages);
if($offset==0)//No Previuos button required and print the other buttons as is
{
}
else//Print the previous button
{
echo "<a href=\"$PHP_SELF?offset=$offset-$limit\"><i>Page 1</i></a>  ";//Prints the Prev link
}
display_records($offset,($offset+$limit));
for($i=0;$i<$no_of_pages;$i++)
{
$offset=1;//Reset $offset to have the page links right i.e. from 1-10, 11-21, 21-31...etc
echo "<a href=\"$PHP_SELF?offset=$offset+($i*$limit)&page_number=".($i+1)."\"><i>Page:".($i+1)."</i></a>  ";//Prints the "Page:#" links
}
//I also am trying to put the Next Button.
}
?>
+++++++++++ SCRIPT ENDS ++++++++++++++++++
Please help me to solve this thing.
Thanks in advance.
--SandyK