> Hi to all, > I'm new to PHP. I'm trying to retrieve data from a database, but I just > want to retrieve one record at a time and go through to the next > records by click next record. I know how to retrieve all record by > using the > mysql_fetch_array, but I'm having problems to select one record at > time. Any idea? > > Thanks in advanced > Nato
Nato, you can use the MySQL LIMIT feature as part of your SELECT statement to accomplish this. $SQL = "SELECT * FROM my_data LIMIT 0, 1"; The result that you get with mysql_fetch_array is only one record, the first record that the database returned from the SELECT statement. When your user presses NEXT, you would execute: $SQL = "SELECT * FROM my_data LIMIT 1, 1"; The second number is the number of records to limit by, in your case only one at a time. The first number is the index of the record that you want to have returned by the database. This number would be a variable in your case that would increment by one when they press NEXT and decrement by one when they press PREVIOUS. Hope that helps you out. Josh -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php