I want a <select> written in php that gets data out of a MYSQL DB out of tabel called "mainmenu" tabefield called "naam" and with the "onchange" I want it redirect to hisself but then an other <select> comes up.
In that other <select> must get data out of the same MYSQL db only from an other table called "submenu"
So the mainmenu select is "telling" the submenu select what data must come up...
I got this programmed by myself but it won''t work.
I am pretty desperate I hope you can help me.
<?php
require ("../connect.php");
$db = mysql_connect('localhost','user','password');
$fields = mysql_list_fields("database", "mainmenu", $db);
$columns = mysql_num_fields($fields);
$query="select id,naam from mainmenu where aktief=1";
$result = MYSQL_QUERY($query) or die(mysql_error());
$data=mysql_fetch_array($result);
if ($result)
{
echo "\nHoofdgroepen: <select name=\"hoofd\" onChange=\"JavaScript.form.submit();\">\n";
echo "<option value=\"\"selected>Select hoofdgroep ....</option>\n";
echo "<option value=\"".$data["id"]."\">".$data["naam"]."</option>\n";
while ($data=mysql_fetch_array($result))
{
echo "<option value=\"".$data["id"]."\">".$data["naam"]."</option>\n";
}
echo "</select>";
}
$SQLconnection = mysql_connect ("localhost", "user","password");
mysql_select_db("database");
$query="select id,naam from submenu where hoofd='$data' and aktief=1";
$result = MYSQL_QUERY($query) or die(mysql_error());
$data=mysql_fetch_array($result);
function sub1 ($hoofd){
if (!empty($result))
{
echo "\Subcategorie: <select name=\"sub\" onChange=\"JavaScript.form.submit();\">\n";
echo "<option value=\"\">Select subcatergorie ....</option>\n";
echo "<option value=\"".$data["id"]."\">".$data["naam"]."</option>\n";
while ($data=mysql_fetch_array ($result))
{
echo "<option value=\"".$data["id"]."\">".$data["naam"]."</option>\n";
}
echo "</select>";
}
}
?>