Crashdowns
Ensign
- Registriert
- Juni 2010
- Beiträge
- 138
Hallo zusammen,
ich arbeite an einem mehrstufigem Auswahlmenü. Zuerst soll eine Universität ausgewählt werden, danach abhängig von dieser Auswahl ein Fach/Kurs und danach noch die Sprache. Die Daten dafür sind in einer DB vorhanden und sollen dort ausgelesen werden. DB auslesen und in das Auswahlmenü eintragen war kein Problem. Mir ist allerdings noch unklar wie ich das zweite/dritte Auswahlmenü abhängig von dem Rückgabewert der vorherigen Auswahl mache.
Hier der momentane Code:
Ich hoffe auf kreative Anregungen oder hilfreiche Tipps
ich arbeite an einem mehrstufigem Auswahlmenü. Zuerst soll eine Universität ausgewählt werden, danach abhängig von dieser Auswahl ein Fach/Kurs und danach noch die Sprache. Die Daten dafür sind in einer DB vorhanden und sollen dort ausgelesen werden. DB auslesen und in das Auswahlmenü eintragen war kein Problem. Mir ist allerdings noch unklar wie ich das zweite/dritte Auswahlmenü abhängig von dem Rückgabewert der vorherigen Auswahl mache.
Hier der momentane Code:
PHP:
<?php require_once('Connections/unimedia.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_unimedia, $unimedia);
$query_Recordset1 = "SELECT switzerland.university FROM switzerland";
$Recordset1 = mysql_query($query_Recordset1, $unimedia) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
mysql_select_db($database_unimedia, $unimedia);
$query_Recordset2 = "SELECT switzerland.course FROM switzerland";
$Recordset2 = mysql_query($query_Recordset2, $unimedia) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>dynamische Drop Down Menu aus Datenbank in abhängigkeit</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<label for="1">University</label>
<select name="1" id="1">
<?php
do {
?>
<option value="<?php echo $row_Recordset1['university']?>"><?php echo $row_Recordset1['university']?></option>
<?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
$rows = mysql_num_rows($Recordset1);
if($rows > 0) {
mysql_data_seek($Recordset1, 0);
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
}
?>
</select>
</form>
<form id="form2" name="form2" method="post" action="">
<label for="2">Course</label>
<select name="2" id="2">
<?php
do {
?>
<option value="<?php echo $row_Recordset2['course']?>"><?php echo $row_Recordset2['course']?></option>
<?php
} while ($row_Recordset2 = mysql_fetch_assoc($Recordset2));
$rows = mysql_num_rows($Recordset2);
if($rows > 0) {
mysql_data_seek($Recordset2, 0);
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
}
?>
</select>
</form>
<p> </p>
</body>
</html>
<?php
mysql_free_result($Recordset1);
mysql_free_result($Recordset2);
?>
Ich hoffe auf kreative Anregungen oder hilfreiche Tipps