im generating a dynamic dropdown and have the page reload with javascript after the first selection has been made.
Once the first value is selected it passes that value into the url which consists of index2.php?option=content and once the value is passed becomes index2.php?option=content&cat=1 (this value changes depending on selection) and reloads the page, the problem i have it getting that value of cat once it has been passed. This is the following php code i use:
echo "<form action=content.php method=get>";
echo "Title:";
echo "<input type=test name=txtTitle /><br />";
require('config.php');
$cat = $_GET['cat'];
//$cat = 1;
//$_GET = array(option => content, cat => $cat);
//$_GET['content'] == $con;
//$_GET['cat'] == $cat;
if(isset($cat) && strlen($cat) > 0) {
$quer=mysql_query("SELECT DISTINCT catid,name FROM CategoryNews where secid=$cat order by name");
} else {
$quer=mysql_query("SELECT DISTINCT catid,name FROM CategoryNews order by name");
}
echo "Secton:";
echo "<select name='cat' onchange=\"reload(this.form)\">
<option value=''> --Select Section-- </option>";
//$quer=mysql_query("select name from Sections");
$quer2=mysql_query("SELECT DISTINCT secid,name FROM Sections order by name");
while($noticia2 = mysql_fetch_array($quer2)) {
if($noticia2['secid']==@$cat) {
echo "<option selected value='$noticia2[secid]'>$noticia2[name]</option>";
} else {
echo "<option value='$noticia2[secid]'>$noticia2[name]</option>";}
}
echo "</select>";
echo "Category:";
echo "<select name='txtCategory'>
<option value=''> --Select Category-- </option>";
while($noticia = mysql_fetch_array($quer)) {
echo "<option value='$noticia[catid]'>$noticia[name]</option>";
}
echo "</select>";
////////////////// This will end the second drop down list ///////////
mysql_close();
echo "</form>";
As you can see i've tryed a number of methods to get the value even assigning the variable a value to ensure the script works, which it does. Any help with this problem or if you require any further info would be greatfully appreciated.
Regards,
Cathal O'Brien