Re: [PHP-DB] returning all rows
Well, then maybe you only have one row with that city in the database? If you want to order, but return all rows, use ORDER BY. Plus, you don't output anything in the while loop - how do you know there's only one row? Bogdan Todd Williamsen wrote: >It needs that line to sort them by city. But it only returns one row > >"Bogdan Stancescu" <[EMAIL PROTECTED]> wrote in message >[EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > >>Just lose the "WHERE city=\"$city\" in the SQL. >> >>Bogdan >> >>Todd Williamsen wrote: >> >>>I know I have asked this silly question before, but forgive me since I >>> >have > >>>been a bit rusty with PHP lately >>> >>>So how do I return all rows? >>> >>>I have this: >>> >>>$sql= "SELECT id, city, date FROM meetings WHERE city = \"$city\" "; >>>$result = mysql_query($sql,$connection) or die("Couldn't execute query"); >>>while ($row = mysql_fetch_array($result)) { >>>$id = $row["id"]; >>>$city = $row["city"]; >>>$date = $row["date"]; >>>} >>>echo "$date"; >>>?> >>> >>> >>> >> >> > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Returning all rows
Echo your data in the loop. like this: $sql= "SELECT id, city, date FROM meetings WHERE city = \"$city\" "; $result = mysql_query($sql,$connection) or die("Couldn't execute query"); while ($row = mysql_fetch_array($result)) { $id = $row["id"]; $city = $row["city"]; $date = $row["date"]; echo "$date"; } - Original Message - From: "Todd Williamsen" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, May 20, 2002 5:01 PM Subject: [PHP-DB] Returning all rows > I know I have asked this silly question before, but forgive me since I have > been a bit rusty with PHP lately > > So how do I return all rows? > > I have this: > > $sql= "SELECT id, city, date FROM meetings WHERE city = \"$city\" "; > $result = mysql_query($sql,$connection) or die("Couldn't execute query"); > while ($row = mysql_fetch_array($result)) { > $id = $row["id"]; > $city = $row["city"]; > $date = $row["date"]; > } > echo "$date"; > ?> > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Returning all rows
Put the echo inside the while statement. HTH Todd Williamsen <[EMAIL PROTECTED]> said: > I know I have asked this silly question before, but forgive me since I have > been a bit rusty with PHP lately > > So how do I return all rows? > > I have this: > > $sql= "SELECT id, city, date FROM meetings WHERE city = \"$city\" "; > $result = mysql_query($sql,$connection) or die("Couldn't execute query"); > while ($row = mysql_fetch_array($result)) { > $id = $row["id"]; > $city = $row["city"]; > $date = $row["date"]; > } > echo "$date"; > ?> > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] returning all rows
It needs that line to sort them by city. But it only returns one row "Bogdan Stancescu" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Just lose the "WHERE city=\"$city\" in the SQL. > > Bogdan > > Todd Williamsen wrote: > > >I know I have asked this silly question before, but forgive me since I have > >been a bit rusty with PHP lately > > > >So how do I return all rows? > > > >I have this: > > > >$sql= "SELECT id, city, date FROM meetings WHERE city = \"$city\" "; > >$result = mysql_query($sql,$connection) or die("Couldn't execute query"); > >while ($row = mysql_fetch_array($result)) { > >$id = $row["id"]; > >$city = $row["city"]; > >$date = $row["date"]; > >} > >echo "$date"; > >?> > > > > > > > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] returning all rows
Just lose the "WHERE city=\"$city\" in the SQL. Bogdan Todd Williamsen wrote: >I know I have asked this silly question before, but forgive me since I have >been a bit rusty with PHP lately > >So how do I return all rows? > >I have this: > >$sql= "SELECT id, city, date FROM meetings WHERE city = \"$city\" "; >$result = mysql_query($sql,$connection) or die("Couldn't execute query"); >while ($row = mysql_fetch_array($result)) { >$id = $row["id"]; >$city = $row["city"]; >$date = $row["date"]; >} >echo "$date"; >?> > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php