|
|
|
ช่วยแก้หน่อยครับผมใช้ Select เพิ่มเมนูแล้วซ้อน Select อีกชั้นโดย Option เอาค่าที่ดึกมาจากฐานข้อมูล |
|
|
|
|
|
|
|
อ่านเพิ่มเติมการทำ Sub Domain ด้วย PHP แบบ Step by Step ครับ
Code
พอกดเพิ่มเมนูเป็นแบบนี้อะครับ
code ครับ
Code (PHP)
<?php require_once('Myconnection.php'); ?>
<?php session_start();
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;
}
} $strSQL = "SELECT DISTINCT Name FROM equipment ";
$equipmentQuery = mysql_query ($strSQL,$Myconnection) or die ("Error Query [".$strSQL."]");
$num=mysql_num_rows($equipmentQuery);
session_write_close();
?>
<html>
<head>
<title>ThaiCreate.Com PHP & MySQL Tutorial</title>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>
<body>
<form action="phpMySQLAddSave.php" name="frmAdd" method="post">
Select Line :
<select name="menu1" onChange="MM_jumpMenu('parent',this,0)">
<?php
for($i=1;$i<=5;$i++)
{
if($_GET["Line"] == $i)
{
$sel = "selected";
}
else
{
$sel = "";
}
?>
<option value="<?php echo $_SERVER["PHP_SELF"];?>?Line=<?php echo $i;?>" <?php echo $sel;?>><?php echo $i;?></option>
<?php
}
?>
</select>
<table width="1000" border="1">
<tr>
<th width="10%"> <div align="center">CustomerID </div></th>
<th width="80%"> <div align="center">Name </div></th>
<th width="10%"> <div align="center">Number </div></th>
</tr>
<?php
@$line = $_GET["Line"];
if($line == 0){$line=1;}
for($i=1;$i<=$line;$i++)
{
?>
<tr>
<td><div align="center"><input type="text" name="txtCustomerID<?php echo $i;?>" size="5" value="<?php echo $i;?>"></div></td>
<td><select name="txtName<?php echo $i;?>" id="List">
<?php while($equipmentResult = mysql_fetch_array($equipmentQuery)){?>
<option value="<?php echo $equipmentResult["Name"];?>"><?php echo $equipmentResult["Name"];?></option>
<?php } ?></select></td>
<td align="right"><input type="text" name="txtNumber<?php echo $i;?>" size="5"></td>
</tr>
<?php
}
?>
</table>
<input type="submit" name="submit" value="submit">
<input type="hidden" name="hdnLine" value="<?php echo $i;?>">
</form>
</body>
<?php mysql_close($Myconnection); ?>
</html>
Tag : PHP, MySQL, HTML/CSS, JavaScript, Ajax, jQuery
|
|
|
|
|
|
Date :
2017-01-22 19:20:49 |
By :
blackjome |
View :
1265 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
น่าจะเหมือนตัวนี้ครับ
createElement('select'); สร้าง Element ของ Select Option พร้อมกับ ดึงข้อมูลจาก MySQL Database ครับ
|
|
|
|
|
Date :
2017-01-23 10:41:20 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|