Hello,
I am scratching my head on this one. I have a function that generates a drop down menu (it has been simplified below).
my issue is with the mysql_result function where I would like to use the $option_value and $option_display parameters. It works fine if I hard code in 0 and 1 instead of the variable.
My question is simple, why and how do I fix it.
Thank you in advance
function ddm($type, $option_value='0', $option_display='1', $name, $default='', $tabindex=''){
conn_db();
$sql = "";
switch($type){
case "group":
$sql .= ('SELECT * FROM student_groups ');
break;
case "grade":
$sql .= ('SELECT * FROM student_grades');
break;
}
if(!($result_ddm = mysql_query($sql))){
die('error utils.inc function drop_menu '.mysql_error());
}
$select .= '<select name="'.$name.'" id="'.$name.'" tabindex="'.$tabindex.'">';
for ($i=0; $i < mysql_numrows($result_ddm); $i++) {
$opt_code = mysql_result($result_ddm, $i, $option_value); //THIS DOES NOT WORK
$opt_desc = mysql_result($result_ddm, $i, $option_display); //THIS DOES NOT WORK
//$opt_code = mysql_result($result_ddm, $i, '0'); THIS WORKS
//$opt_desc = mysql_result($result_ddm, $i, '1'); THIS WORKS
$select .= '<option value="'.$opt_code.'"';
$select .= ">$opt_desc</option>";
}
$select .= "</select>\n";
return($select);
}