Page 1 of 1

create pulldowm

Posted: Mon Aug 16, 2004 1:25 pm
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

Posted: Mon Aug 16, 2004 2:25 pm
by juline
:cry: :cry:
is it actually possible ?

Posted: Mon Aug 16, 2004 2:47 pm
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>

Posted: Mon Aug 16, 2004 2:59 pm
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 ?