السلام عليكم
علمت انة لا يمكن ربط 2 قائمة منسدلة مع بعضهم البعض الا بطريقتيين
الاولي هي استخدام الاجاكس
الثانية عن طريق جافا سكريبت
ها انا اخترت الجافا اسكربت واريد ان اعرف ما هي الطريق
اليكم الكود التالي
وفية
استعلام باسماء الاشخاص
واستعلام باسماء المنتجات
اريد لكل شخص يظهر منتجاتة فقط اي عند اختيار اسم الشخص يظهر المنتجات التي تخصة فقط وشكرا
<?php require_once('Connections/test.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_test, $test);
$query_Recordset1 = "SELECT products.product_name, customers.customer_name FROM products, customers WHERE customers.customer_id = products.customer_id";
$Recordset1 = mysql_query($query_Recordset1, $test) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!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>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<p>
<label for="customer_name">customer_name</label>
<select name="customer_name" id="customer_name" title="<?php echo $row_Recordset1['customer_name']; ?>">
<?php
do {
?>
<option value="<?php echo $row_Recordset1['customer_name']?>"><?php echo $row_Recordset1['customer_name']?></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>
</p>
<p>
<label for="product_name">product_name</label>
<select name="product_name" id="product_name" title="<?php echo $row_Recordset1['product_name']; ?>">
<?php
do {
?>
<option value="<?php echo $row_Recordset1['product_name']?>"><?php echo $row_Recordset1['product_name']?></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>
</p>
</form>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>