Gday,
So I have a mysql data base and run a query in php which spits out the following info when i do a var_dump() (I'm retrieving the mysql results using mysql_fetch_array):
Please ignore the actual content - its just dummy content.
Now there should actually be a number of records. But I can only seem to access the first row of results. This is what PHPAdmin spits out when I run the same query:
As you can see, there are 5 rows of results that should be returned.
Now I know this might seem like a silly problem that is no doubt an 'SQL/PHP 101' sort of thing, but i'm only just learning php and mysql. I know there are probably pre-written scripts to help me here but I like to "re-invent the wheel" when i'm learning so that i completely understand what is going on.
How do I loop through each row that the mysql query should return?
Cheers,
Richard
So I have a mysql data base and run a query in php which spits out the following info when i do a var_dump() (I'm retrieving the mysql results using mysql_fetch_array):
| Code: |
|
array(12) { [0]=> string(2) "12" ["artist_id"]=> string(2) "12" [1]=> string(19) "The Pussy Cat Dolls" ["artist_name"]=> string(19) "The Pussy Cat Dolls" [2]=> string(21) "www.pussycatdolls.com" ["artist_website"]=> string(21) "www.pussycatdolls.com" [3]=> string(1) "2" ["album_id"]=> string(1) "2" [4]=> string(4) "Don\" ["album_name"]=> string(4) "Don\" [5]=> string(4) "2004" ["album_releasedate"]=> string(4) "2004" } |
Please ignore the actual content - its just dummy content.
Now there should actually be a number of records. But I can only seem to access the first row of results. This is what PHPAdmin spits out when I run the same query:
| Code: |
| artist_id artist_name artist_website album_id album_name album_releasedate
12 The Pussy Cat Dolls www.pussycatdolls.com 2 Don\ 2004 12 The Pussy Cat Dolls www.pussycatdolls.com 3 Don%5C%27t+Cha+10%5C%22 2004 12 The Pussy Cat Dolls www.pussycatdolls.com 4 Don%5C%27t+Cha+10%5C%22 2004 12 The Pussy Cat Dolls www.pussycatdolls.com 5 Don%5C%27t+Cha+%5C%2210 0000 12 The Pussy Cat Dolls www.pussycatdolls.com 6 Don%27t+Cha+10%22 0000 |
As you can see, there are 5 rows of results that should be returned.
Now I know this might seem like a silly problem that is no doubt an 'SQL/PHP 101' sort of thing, but i'm only just learning php and mysql. I know there are probably pre-written scripts to help me here but I like to "re-invent the wheel" when i'm learning so that i completely understand what is going on.
How do I loop through each row that the mysql query should return?
Cheers,
Richard
