newbie here. I have wrote scripts in .t and .tea for over 3 years @work.
I'm switching over to php/mysql for my land cruiser site. I would like ideas
and code examples on how to do a certain operation.
I have a vehicle registry where a user enters their info along with
the info of their cruizer. I know how to enter and retrieve the data with no problem at all.
for example:
lets say I have 30 entries into the database. when a user clicks on my reg
index page I would like to grab the first 5 entries (1-5) and display them, with a next 5 link at the bottom linking to the next 5 entries in the db. On that page it would show a previous and next link also.
how would everyone here go about doing the count in the for() to only showing 5 at a time.
thanks,
rodney
code ideas for a php / mysql script.
Moderator: General Moderators
How about this:
That should work but I haven't tested it.
Code: Select all
<?
if(!isset($_GETї'start'])) {
$_GETї'start'] = 0;
}
$result = mysql_query("SELECT * FROM table limit ".$_GETї'start'].",5");
while($row = mysql_fetch_array($result))
{
echo "$row<br>";
}
$total = mysql_query("SELECT * FROM table");
if($_GETї'start'] >= 5) echo "<a href="". $_SERVERї'PHP_SELF']."?start=".$_GETї'start']-5."">Prev</a>";
if($_GETї'start'] < mysql_num_rows($total)) echo " <a href="". $_SERVERї'PHP_SELF']."?start=".$_GETї'start']+5."">Next</a>";
?>thanks
thanks that is close to what I have..I will give this a try and let you know..
thanks again
thanks again