Ik heb het voor elkaar gekregen om deze combined comboboxen uit een database te halen via een script die ik heb gedownload.
Nu weet ik alleen niet precies wat alles doet. Zou iemand mij misschien wat uitleg kunnen geven hierbij. bij voorbaat dank.



<?php virtual('/Connections/opdracht1.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $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_opdracht1, $opdracht1);
$query_Recordset1 = "SELECT * FROM provincie ORDER BY provincie.ID";
$Recordset1 = mysql_query($query_Recordset1, $opdracht1) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=shift_jis">
<title>Untitled Document</title>
<script language="javascript">
var xmlHttp

function showLanden(str)
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }

var url="file2.php";
url=url+"?q="+str;



xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged()
{
if (xmlHttp.readyState==4)
{
document.getElementById("txtHint").innerHTML=xmlHttp.responseText;

}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}
</script>

</head>

<body>


<form action="" method="get" enctype="multipart/form-data" name="frmAjax" id="frmAjax">

<table width="100" border="1">
  <tr>
    <td>Provincie</td>
    <td>
	<select name="country" id="country" onchange="showLanden(this.value)">
	  <?php
do {  
?>
	  <option value="<?php echo $row_Recordset1['ID']?>"><?php echo $row_Recordset1['Naam']?></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>
	
	</td>
  </tr>
  <tr>
    <td>Stad</td>
    <td><p><div id="txtHint">
	<select name="state" id="state" style="width:110px; ">
				 <option value="0">Select</option>
      </select>
	</div>
</p></td>
  </tr>
</table>

</form>

</body>
</html>
<?php
mysql_free_result($Recordset1);
?>




<?php virtual('/Connections/opdracht1.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $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_opdracht1, $opdracht1);
$query_Recordset1 = "SELECT * FROM stad  WHERE stad.Provincie_id = '".$_GET['q']."'";
$Recordset1 = mysql_query($query_Recordset1, $opdracht1) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=shift_jis">
<title>Untitled Document</title>
</head>
<body>

<form action="" method="post" enctype="multipart/form-data">
<table width="100" border="1">
  <tr>
    <td><select name="state" id="state">
      <?php
do {  
?><option value="<?php echo $row_Recordset1['Provincie_id']?>"><?php echo $row_Recordset1['stad']?></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></td>
  </tr>
</table>
</form>

</body>
</html>
<?php
mysql_free_result($Recordset1);
?>

Reageren