Re: [PHP-DB] php/mySQL help
Addressed to: "Stinsman, Scott" <[EMAIL PROTECTED]> [EMAIL PROTECTED] ** Reply to note from "Stinsman, Scott" <[EMAIL PROTECTED]> Wed, 7 Feb 2001 16:00:29 -0500 > > Hi everyone..been away and off the list for awhile.i am back to work and > need some help. I am not sure if I am having a problem with my PHP or > mySQL. > I have a table called "Restaurant" with a field called "Cuisine". There are > 5 records in this table. When I run my code, it only returns one cuisine > when there are 5. I am trying to get all the Cuisines in the array called > CuisineMenuArray with no duplicates so I can generate a drop-down menu of > cuisines "on the fly". > Any help would be greatly appreciated! Thanx. > > Here is the code: > > $db=mysql_connect("localhost", "***", ""); > > mysql_select_db("quickcit", $db) OR DIE ("died at connect"); > > $query = "SELECT Restaurant.Cuisine "; > $query .= "FROM Restaurant "; > $query .= "ORDER BY Restaurant.Cuisine ASC "; > $mysql_result=mysql_query($query, $db) OR DIE ("died at query"); > Try changing you Query to: SELECT DISTINCT Cuisine FROM Restaurant ORDER BY Cousine Then rely on the DISTINCT to insure you only get one copy of the value in your array. while( list( $Couisine ) = mysql_fetch_row( $Result )) { $CouisineList[] = $Couisine; } And you are done... Rick Widmer Internet Marketing Specialists http://www.developersdesk.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] php/mySQL help
got it!! just needed an echo "$select"; thanx man! this has helped immensely! --scott -Original Message- From: Stinsman, Scott Sent: Wednesday, February 07, 2001 4:42 PM To: Stinsman, Scott; '[EMAIL PROTECTED]' Subject: RE: [PHP-DB] php/mySQL help I made some changes and the page is up but there is no drop-down menu.don't i have to add some echo statements in here? --scott -Original Message- From: Stinsman, Scott [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 07, 2001 4:29 PM To: '[EMAIL PROTECTED]'; '[EMAIL PROTECTED]' Subject: RE: [PHP-DB] php/mySQL help thanx andy-- i put this code on my page and now my whole page is blank. any clues? -Original Message- From: Andrew Rush [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 07, 2001 4:14 PM To: Stinsman, Scott Subject: Re: [PHP-DB] php/mySQL help On Wednesday, February 7, 2001, at 04:00 PM, Stinsman, Scott wrote: > $db=mysql_connect("localhost", "***", ""); > > mysql_select_db("quickcit", $db) OR DIE ("died at connect"); > > $query = "SELECT DISTINCT Restaurant.Cuisine "; notice the addition of the DISTINCT keyword. this will keep this code useable when you get more than one type of restaurant for each cuisine type > $query .= "FROM Restaurant "; > $query .= "ORDER BY Restaurant.Cuisine ASC "; if($result=mysql_query($query, $db) OR DIE ("died at query")) { $select="\n"; while(list($cuisine)=mysql_fetch_array($result)) { $select.="$cuisine\n"; } $select.=""; } :: Andrew Rush :: Lead Systems Developer :: MaineToday.com :: ** "Crippled but free, blind all the time, i was learning to see" - J. Garcia / R. Hunter ** The views expressed herein are not necessarily those of my employer, but they let me have them anyway. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] php/mySQL help
I made some changes and the page is up but there is no drop-down menu.don't i have to add some echo statements in here? --scott -Original Message- From: Stinsman, Scott [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 07, 2001 4:29 PM To: '[EMAIL PROTECTED]'; '[EMAIL PROTECTED]' Subject: RE: [PHP-DB] php/mySQL help thanx andy-- i put this code on my page and now my whole page is blank. any clues? -Original Message- From: Andrew Rush [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 07, 2001 4:14 PM To: Stinsman, Scott Subject: Re: [PHP-DB] php/mySQL help On Wednesday, February 7, 2001, at 04:00 PM, Stinsman, Scott wrote: > $db=mysql_connect("localhost", "***", ""); > > mysql_select_db("quickcit", $db) OR DIE ("died at connect"); > > $query = "SELECT DISTINCT Restaurant.Cuisine "; notice the addition of the DISTINCT keyword. this will keep this code useable when you get more than one type of restaurant for each cuisine type > $query .= "FROM Restaurant "; > $query .= "ORDER BY Restaurant.Cuisine ASC "; if($result=mysql_query($query, $db) OR DIE ("died at query")) { $select="\n"; while(list($cuisine)=mysql_fetch_array($result)) { $select.="$cuisine\n"; } $select.=""; } :: Andrew Rush :: Lead Systems Developer :: MaineToday.com :: ** "Crippled but free, blind all the time, i was learning to see" - J. Garcia / R. Hunter ** The views expressed herein are not necessarily those of my employer, but they let me have them anyway. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] php/mySQL help
thanx andy-- i put this code on my page and now my whole page is blank. any clues? -Original Message- From: Andrew Rush [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 07, 2001 4:14 PM To: Stinsman, Scott Subject: Re: [PHP-DB] php/mySQL help On Wednesday, February 7, 2001, at 04:00 PM, Stinsman, Scott wrote: > $db=mysql_connect("localhost", "***", ""); > > mysql_select_db("quickcit", $db) OR DIE ("died at connect"); > > $query = "SELECT DISTINCT Restaurant.Cuisine "; notice the addition of the DISTINCT keyword. this will keep this code useable when you get more than one type of restaurant for each cuisine type > $query .= "FROM Restaurant "; > $query .= "ORDER BY Restaurant.Cuisine ASC "; if($result=mysql_query($query, $db) OR DIE ("died at query")) { $select="\n"; while(list($cuisine)=mysql_fetch_array($result)) { $select.="$cuisine\n"; } $select.=""; } :: Andrew Rush :: Lead Systems Developer :: MaineToday.com :: ** "Crippled but free, blind all the time, i was learning to see" - J. Garcia / R. Hunter ** The views expressed herein are not necessarily those of my employer, but they let me have them anyway. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]