Ok I have a table with a few fields. One of the fields is username. There are many times where the username is the same, for example:
-
- username: bob
- password: bob
- report: 1
-
- username: bob
- password: bob
- report: 2
I did a SQL statement to select * where username='bob'; but when I do the following PHP function, it will only return the last result:
$thisrow = mysql_fetch_row($result);
I need to get every field from every row. How should I go about doing this?
$mainsection='auth'; //The name of the table $query1='select * from auth where username='$user''; $result = mysql_db_query($dbname, $query1) or die('Failed Query of ' . $query1); //do the query $thisrow=mysql_fetch_row($result); echo 'Study: ' . $thisrow[1] . ' - ' . $thisrow[5];
Sorry for such a dumb question. I can’t seem to get the while loops of more than one field working for the life of me.
mysql_fetch_rowfetches each row one at a time. In order to retrieve multiple rows, you would use awhileloop like this: