PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 8th, 1999, 02:23 AM
tucats
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
I am putting together a database that includes states and cities... Each state has multiple listings in my database and also, each city has multiple listings in my database... When I call for a list of cities, I only want the cities to appear once, not multiple times... how do I do this... here is part of my script... I am really new at this so please forgive me if it is a really easy answer...

Thank you...

$result = mysql_query("SELECT * FROM $state",$db);

if ($myrow = mysql_fetch_array($result)) {


?>

<form method="post" action="cities.php3">
<p>
<select name="state"><?php


printf("<option selected>
$staten");?>

</select>

<select name="cities">
<option selected>Select a City</option><?php
do {

printf("<option>%sn", $myrow["City"]);

} while ($myrow = mysql_fetch_array($result));

echo "n";

?>

</select>

Reply With Quote
  #2  
Old December 8th, 1999, 09:02 AM
Hans
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
How about using SELECT DISTINCT? Maybe that solves your problem.

Reply With Quote
  #3  
Old December 8th, 1999, 10:02 PM
Darguz
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
As Hans says, the DISTINCT keyword will do it for you. An example:

$Query = "SELECT DISTINCT City from State";

------------------
Alan Little
Holotech Web Design
www.holotech.net/


[This message has been edited by Darguz (edited 12-08-99).]

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Retrieving selected results

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap