Getting values from MySQL array
Posted: Sat Jan 30, 2010 6:54 am
Hi everyone, I 'm having trouble when getting the value from the MySQL DB, databse as shown:
table name: animal
name |type |number
------------------------
John | cat | 5
John | dog | 6
John | fish | 3
Adam | bird | 4
I want to show all types(under John) from an array by:
$query = "SELECT * FROM `animal` WHERE `name`='John' ";
$result = mysql_query( $query) or die ("didn't query");
while ($row = mysql_fetch_array($result)) {
print $row[1];}
But I'm getting catdogfish, is there any way I can get it seperate so i can assign them in different variable? many thx
table name: animal
name |type |number
------------------------
John | cat | 5
John | dog | 6
John | fish | 3
Adam | bird | 4
I want to show all types(under John) from an array by:
$query = "SELECT * FROM `animal` WHERE `name`='John' ";
$result = mysql_query( $query) or die ("didn't query");
while ($row = mysql_fetch_array($result)) {
print $row[1];}
But I'm getting catdogfish, is there any way I can get it seperate so i can assign them in different variable? many thx