I have this simple script:


// MySQL Connection
mysql_connect($sql['host'],$sql['user'],$sql['pass']) or die("Unable to connect to SQL server");
mysql_select_db($sql['data']) or die("Unable to find DB");

// Getting rows
$select = "SELECT * FROM table WHERE uid = '". $_POST['uid'] ."'";
$data = mysql_db_query($sql['data'], $select) or die("Select Failed!");

// Query results
$row = mysql_fetch_array($data);
$id = $row['uid'];
$type = $row['type'];
print("$id - $type");


This is the simple version. The table has alot of items all having an uid number. Also a type is choosen for each item. When viewing an item i want an 'next' and 'previous' link going to the next item and previous item for the selected type.

Let say i have 5 item with the type "Type1". The 5 items will have the uid numbers: 1, 5, 8, 14 and 15. I want to make a 'next' and 'previous' link, that links to the respective item.

Is there a simple way the get the result from MySQL and is there a simple way to go to the next result and the prevois result??

Pass the current row count as a variable to the query.
At each result row add
<? $goin_back = $row_num - 1;
$goin_ahead = $row_num + 1; ?>

<a href="?row_num=<? echo $goin_back;?>">Back</a> ||
<a href="?row_num=<? echo $goin_ahead;?>">Forward</a>

Then your query does a:
SELECT * FROM table LIMIT $row_num , 1

Make sense?

Hellou can you help me please with this.
All is going right but when i am on the end of mysql it didn`t show me anything.
Can you tell me way how to hide next or preview link when next or preview row doesn`t exist?
Or how to stay on row ?

thank you for reply.