create pulldowm

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
juline
Forum Commoner
Posts: 37
Joined: Thu Jul 15, 2004 9:05 am

create pulldowm

Post by juline »

hi friends,

i have a query which is filtering 2 varibles over 3 tables which i want to be displayed in a pulldown button. how do i do that ?

Code: Select all

$query ="select drinks.description, barkeeper.username from drinksBarkeeper, barkeeper, drinks	where barkeeper.drinksBarkeeper.user_nr	and drinks.drinks_nr=drinksBarkeeper.drinks_nr";
thanks for help in advance !

juline
juline
Forum Commoner
Posts: 37
Joined: Thu Jul 15, 2004 9:05 am

Post by juline »

:cry: :cry:
is it actually possible ?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

I'm not entirly sure what you're asking, but if you're talking about creating a select box based on database values then the usual way to do it is something like:

Code: Select all

<?php
$sql = ' .... ';
$opts = array();
$res = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($res)){
    $opts[] = $row['description'];
}
?>
<select name="whatever">
<?php
foreach($opts as $opt){
    echo '<option value="'.$opt.'">'.$opt.'</option>';
}
?>
</select>
juline
Forum Commoner
Posts: 37
Joined: Thu Jul 15, 2004 9:05 am

Post by juline »

hi markl999,

thanx for answering. actually i am pooling two variables bye the query ($drink and §barkeeper) which are in an n:m relation. so i use a connection table called drinkBarkeeper. and what i want is to diplay these variables next to next in the pulldown.
e.g. drinkw1 keeper3

could i make it clear dear ?
Post Reply