 |
สอบถามข้อมูลเกี่ยวกับการรับค่าไป update เข้าไปใน table ครับผม |
|
 |
|
|
 |
 |
|
form รับของผมเป็นแบบนี้ อยาก update เข้าไปใน table ต้อง ใส่ coed ยังไงใน save_main.php ครับ
Code
CREATE TABLE `main` (
`device` varchar(32) NOT NULL,
`model` varchar(50) NOT NULL,
`name` varchar(32) NOT NULL,
`ip` varchar(30) NOT NULL,
`location_id` int(4) NOT NULL,
`serial_number` varchar(50) NOT NULL,
`status` varchar(20) NOT NULL,
`last_update` date NOT NULL,
`attachment` varchar(32) NOT NULL
)
Code
<form name="form1" method="post" action="save_main.php">
<FONT FACE="arial"><table width="400" border="0" style="width: 600px">
<ul class="blue">
<tbody>
<tr>
<td><a></t>Device</a></td>
<td>
<label>
<select name="lmName1">
<option value="">- Select Device</option>
<?
$strSQL = "SELECT * FROM main status group by device ORDER BY device";
$objQuery = mysql_query($strSQL);
while($objResuut = mysql_fetch_array($objQuery))
{
?>
<option value="<?=$objResuut["device"];?>"><?=$objResuut["device"];?></option>
<?
}
?>
</select>
</label>
</td>
</tr>
<tr>
<tr>
<td>Model</td>
<td>
<select name="lmName2">
<option value="">- Select Model</option>
<?
$strSQL = "SELECT * FROM main group by model ORDER BY model ";
$objQuery = mysql_query($strSQL);
while($objResuut = mysql_fetch_array($objQuery))
{
?>
<option value="<?=$objResuut["model"];?>"><?=$objResuut["model"];?></option>
<?
}
?>
</select>
</td>
</tr>
<td>Node</td>
<td>
<select name="lmName3" onchange="selectarea(this.value)">
<option value="">- Location Node</option>
<?
$strSQL = "SELECT * FROM location group by location_name ORDER BY location_name";
$objQuery = mysql_query($strSQL);
while($objResuut = mysql_fetch_array($objQuery))
{
?>
<option value="<?=$objResuut["location_name"];?>"><?=$objResuut["location_name"];?></option>
<?
}
?>
</select>
</td>
</tr>
</tr>
<tr>
<td><a></t>Sub Node</a></td>
<td>
<label>
<select name="lmName4">
<option value="">- Select Sub Model</option>
<?
$strSQL = "SELECT * FROM location WHERE sub_location != ' ' ORDER BY sub_location ";
$objQuery = mysql_query($strSQL);
while($objResuut = mysql_fetch_array($objQuery))
{
?>
<option value="<?=$objResuut["sub_location"];?>"><?=$objResuut["sub_location"];?></option>
<?
}
?>
</select>
</label>
</td>
</tr>
<tr>
<td><a></t>Status</a></td>
<td>
<label>
<select name="lmName5">
<option value="">- Status</option>
<?
$strSQL = "SELECT * FROM main group by status ORDER BY status ";
$objQuery = mysql_query($strSQL);
while($objResuut = mysql_fetch_array($objQuery))
{
?>
<option value="<?=$objResuut["status"];?>"><?=$objResuut["status"];?></option>
<?
}
?>
</select>
</label>
</td>
</tr>
<tr>
<tr>
<td>Name</td>
<td>
<input name="txtName" type="text" id="txtName" value="<?=$objResult["name"];?>">
</td>
</tr>
<tr>
<td>ip</td>
<td><input name="txtIP" type="text" id="txtName" value="<?=$objResult["ip"];?>">
</td>
</tr>
<tr>
<tr>
<td>Serial Number</td>
<td><input name="txtSN" type="text" id="txtName" value="<?=$objResult["serial_number"];?>">
</td>
</tr>
<tr>
<tr>
<td></td>
<td><BR><BR>
<input type="submit" name="Submit" value="Save">
</td>
</tr>
</tbody>
</table></FONT>
<br>
</form>
ขอบคุณมากครับ
Tag : PHP, MySQL, HTML/CSS
|
|
 |
 |
 |
 |
Date :
2012-09-10 11:50:23 |
By :
yingkhun |
View :
963 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อ่านดูครับ
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com PHP & MySQL Tutorial</title>
</head>
<body>
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "UPDATE customer SET ";
$strSQL .="CustomerID = '".$_POST["txtCustomerID"]."' ";
$strSQL .=",Name = '".$_POST["txtName"]."' ";
$strSQL .=",Email = '".$_POST["txtEmail"]."' ";
$strSQL .=",CountryCode = '".$_POST["txtCountryCode"]."' ";
$strSQL .=",Budget = '".$_POST["txtBudget"]."' ";
$strSQL .=",Used = '".$_POST["txtUsed"]."' ";
$strSQL .="WHERE CustomerID = '".$_GET["CusID"]."' ";
$objQuery = mysql_query($strSQL);
if($objQuery)
{
echo "Save Done.";
}
else
{
echo "Error Save [".$strSQL."]";
}
mysql_close($objConnect);
?>
</body>
</html>
Go to : PHP MySQL Edit/Update Record
|
 |
 |
 |
 |
Date :
2012-09-10 11:57:45 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากครับ
|
 |
 |
 |
 |
Date :
2012-09-12 12:10:04 |
By :
yingkhun |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|