MySQL Forums
Forum List  »  Newbie

Won't select all the rows...
Posted by: Skara
Date: March 16, 2005 03:54PM

Hmm.. I'm using MySQL to store information about books I've read and I'm having trouble reading the data.
I have a table that has two columns, name and author (I'll add more later). I've got most every page working except where I read all the books by a certain author. Now I COULD select all the information and iterate through it, but I'd rather just select the pertinent data and slap it on the page.
Anyway, here's basically what I have:

$query = "SELECT name FROM books_list WHERE author = '" . $_POST['selection'] . "'";
$list = mysql_query($query);
$foo = mysql_fetch_array($list);
print('<p><b>' . $_POST['selection'] . '</b></p>');
for ($i=0; $i < count($foo)-1; $i++) {
print($foo[$i] . '<br />');
}

Problem is it only selects the first book in the table and that's it. O.o What am I doing wrong?

Options: ReplyQuote


Subject
Written By
Posted
Won't select all the rows...
March 16, 2005 03:54PM
March 16, 2005 04:39PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.