Re: [PHP-DB] retrieving one record at a time

2002-03-27 Thread Josh Trutwin

 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




Re: [PHP-DB] retrieving one record at a time

2002-03-27 Thread mike

try using your id column of the table

Select * from table where table_id=1
using mysql_fetch_array with the above query will work.

Mike
- Original Message -
From: Natividad Castro [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, March 27, 2002 5:04 PM
Subject: [PHP-DB] retrieving one record at a time


 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


 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.330 / Virus Database: 184 - Release Date: 2/28/02


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php