Results 1 to 2 of 2
Oct 20, 2001, 00:37 #1
How to loop through all rows in mySQL
I need to loop through all the rows in my SQL table and process each row individually. How can we do that?
I tried "Select * from tablename" and then set up a for loop, but that simply gets the table. How can I go through each row of the table individually?
Oct 20, 2001, 02:34 #2
- Join Date
- Oct 2000
- 0 Post(s)
- 0 Thread(s)
Umm something like this should work:
$sql = "SELECT * FROM mytable";
if(!$result = mysql_query($sql))
die("Couldn't run query"):
while($row = mysql_fetch_array($result))
// Do what you want to $row, its now an array of the current row.