|
 |
|
เกี่ยวกับ การตรวจสอบข้อมูลซ้ำ แล้วเลือกจะดำเนินการต่อหรือกลับไปแก้ไข |
|
 |
|
|
 |
 |
|
การตรวจสอบข้อมูลซ้ำ แล้วเลือกจะดำเนินการต่อหรือกลับไปแก้ไข ครับ พอมีตัวอย่างไหมครับ
โค๊ด
$sql="select * from tb_service where (hn='$hn') and (id_vac='$vaccine') and (num='$vaccineNo') and (date_ser='$day')";
$query=mysql_query($sql);
$numrows=mysql_num_rows($query);
if($numrows>0){
echo "<h1 align=center>บันทึกข้อมูลการฉีดยา ซ้ำชนิด !! </h1></br>";
echo "<center><input type='button' value='ดำเนินการต่อ' OnClick='javascript:fncGo()'
'><input type='button' value='กลับไปแก้ไข' onclick='history.back();'></center></body></html>" ;
exit();
}else{
$sql_add2="INSERT INTO tb_service (date_ser,hn,id_vac,num,unit,name,date_insert) VALUES ('$date_ser','$hn','$vaccine','$vaccineNo','$unit','$name','$day') ";
$query_add2=mysql_query($sql_add2);
if($query_add2){
echo"<h1 align=center>บันทึกข้อมูลเรียบร้อยแล้ว</h1>";
echo "<meta http-equiv='refresh' content='2; url=service.php'>" ;
}else {
echo "<h1 align=center>ไม่สามารถเพิ่มข้อมูลได้</h1>";
echo "<meta http-equiv='refresh' content='2; url=service.php'>" ;
}
}
}
Tag : PHP, MySQL

|
|
 |
 |
 |
 |
Date :
2011-06-10 11:34:15 |
By :
pumin99 |
View :
998 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
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 = "SELECT * FROM customer WHERE CustomerID = '".$_POST["txtCustomerID"]."' ";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
if($objResult)
{
echo "CustomerID already exist.";
}
else
{
$strSQL = "";
$strSQL = "INSERT INTO customer ";
$strSQL .="(CustomerID,Name,Email,CountryCode,Budget,Used) ";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["txtCustomerID"]."','".$_POST["txtName"]."','".$_POST["txtEmail"]."' ";
$strSQL .=",'".$_POST["txtCountryCode"]."','".$_POST["txtBudget"]."','".$_POST["txtUsed"]."') ";
$objQuery = mysql_query($strSQL);
if($objQuery)
{
echo "Save Done.";
}
else
{
echo "Error Save [".$strSQL."]";
}
}
mysql_close($objConnect);
?>
</body>
</html>
|
 |
 |
 |
 |
Date :
2011-06-10 12:40:50 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|