gegevens uit database in drpdownmenu
Wat ik wil is gegevens uit een database haalt, en dan in een dropdownmenu zet.
Ik kan zelf nisk vinden op Google of iets dergelijks...
sql query uitvoeren
<select name="blah">
en dan een for loop :/
:| Voorbeeld?
Code (php)
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
<?php
$query = mysql_query("SELECT * FROM `de tabel`");
echo "<option name=\"blah\">";
while($obj = mysql_fetch_object($query)){
echo "<select name=\"$obj->naam\">$obj->naam</select>";
}
echo "</option>";
?>
$query = mysql_query("SELECT * FROM `de tabel`");
echo "<option name=\"blah\">";
while($obj = mysql_fetch_object($query)){
echo "<select name=\"$obj->naam\">$obj->naam</select>";
}
echo "</option>";
?>
zo ongeveer?
Zoek hier eens op dropdown
Code (php)
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
<?php
error_reporting ( E_ALL );
include("connect.php")
$query = mysql_query("SELECT * FROM `producttable`");
echo "<option name=\"blah\">";
while($obj = mysql_fetch_object($query)){
echo "<select name=\"$obj->naam\">$obj->naam</select>";
}
echo "</option>";
?>
error_reporting ( E_ALL );
include("connect.php")
$query = mysql_query("SELECT * FROM `producttable`");
echo "<option name=\"blah\">";
while($obj = mysql_fetch_object($query)){
echo "<select name=\"$obj->naam\">$obj->naam</select>";
}
echo "</option>";
?>
<select name='bla'>
<option value='1'>1e keus</option>
<option value='2'>2e keus</option>
<option value='3'>3e keus</option>
</select>
nu snap ik er helemaal niks meer van :|
Code (php)
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
<?php
error_reporting ( E_ALL );
include("connect.php")
$query = mysql_query("SELECT * FROM `producttable`");
echo "<select name=\"blah\">";
while($obj = mysql_fetch_object($query)){
echo "<option value=\"$obj->naam\">$obj->naam</option>";
}
echo "</select>";
?>
error_reporting ( E_ALL );
include("connect.php")
$query = mysql_query("SELECT * FROM `producttable`");
echo "<select name=\"blah\">";
while($obj = mysql_fetch_object($query)){
echo "<option value=\"$obj->naam\">$obj->naam</option>";
}
echo "</select>";
?>
Select en option waren verwisseld.
Parse error: parse error, unexpected T_VARIABLE in /data/members/paid/e/x/expodek.nl/htdocs/www/djmagich/test/tst.php on line 4
Code (php)
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
<?php
error_reporting ( E_ALL );
include("connect.php");
$query = mysql_query("SELECT * FROM `producttable`");
echo "<select name=\"blah\">";
while($obj = mysql_fetch_object($query)){
echo "<option value=\"$obj->naam\">$obj->naam</option>";
}
echo "</select>";
?>
error_reporting ( E_ALL );
include("connect.php");
$query = mysql_query("SELECT * FROM `producttable`");
echo "<select name=\"blah\">";
while($obj = mysql_fetch_object($query)){
echo "<option value=\"$obj->naam\">$obj->naam</option>";
}
echo "</select>";
?>
( een ; vergeten )
Iets zelf doen mag ook wel...