Re: MYSQL Question

From: Date: Wed, 28 Jun 2000 15:21:07 +0000
Subject: Re: MYSQL Question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-3571@lists.php.net to get a copy of this message
At 11:08 AM -0400 06-28-2000, Nashirak Bosk wrote:
I have been dwelling on a small problem though that mabye you guys could help me with. I am kina new to MYSQL and am trying to write a datbase program. I have a program to insert a record and retreive a record, but I need some type of program to update it. OK I know there is a UPDATE command in MYSQL, but I want to go row by row updating certain parts of a record. So I have two questions:
       1.  Is there sometype of MYSQL command or PHP3 function to get 1
row and then get the following row after that, and so on...until the last row and then stop editing.
You can retrieve the result set and then move back and forth in it using mysql_data_seek() to position to the record you want. Be aware, however, that you're working with data held on the client end, and someone else may update the data while you're working with it, too.
       2.  Is there some function that tells how many records are in a
table?
SELECT COUNT(*) FROM tbl_name is the fastest query for this. It's optimized to return quickly. Retreive the first (and only) row of the result set, then check the first column of the row. if (!($result = mysql_query ("SELECT COUNT(*) FROM tbl_name"))) die ("query failed"); if (!($row = mysql_fetch_array ($result))) die ("fetch failed"); $count = $row[0]; -- Paul DuBois, paul@snake.net

« previous php.general (#3571) next »