RE: [PHP] MYSQL Question

From: Date: Wed, 28 Jun 2000 15:13:11 +0000
Subject: RE: [PHP] MYSQL Question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-3567@lists.php.net to get a copy of this message
If you want to go row by row through the result of your query, you can do something like this: $sqlstr = "Your SQL string" ; $result = mysql("your_database", $sqlstr, $your_link_identifier) ; while ($result_array = mysql_fetch_array($result)) { Do the stuff that you want to do for each record of the result set } If you want to find out the number of rows that are in your table, you can do it from the command line within MySQL by doing a "select count(*) from table_name" Or if you need to do it in PHP: $sqlstr = "SELECT count(*) as row_count from table_name" ; $result = mysql("your_database", $sqlstr, $your_link_identifier) ; $result_array = mysql_fetch_array($result) ; $row_count = $result_array["row_count"] ; echo $row_count; Hope this helps :) Sam Masiello System Analyst Chek.Com (716) 853-1362 x289 smasiello@chekinc.com -----Original Message----- From: Nashirak Bosk [mailto:nashirak@mindspring.com] Sent: Wednesday, June 28, 2000 11:09 AM To: php-general@lists.php.net Subject: [PHP] MYSQL Question 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. 2. Is there some function that tells how many records are in a table? Thanks, Nashirak -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#3567) next »