SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
-
Oct 20, 2001, 00:37 #1
How to loop through all rows in mySQL
Hi all,
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?
Thanks.
-
Oct 20, 2001, 02:34 #2
- Join Date
- Oct 2000
- Location
- Edmonton
- Posts
- 102
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Umm something like this should work:
PHP Code:
$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.
echo $row['my_column'];
}
Bookmarks