|
|
|
คำสั่ง check record ว่ามีอยู่เท่าไรแล้วไม่ให้ทำ ตามเงือนไขบางอย่าง |
|
|
|
|
|
|
|
select count
ออกมาดูครับ ว่ามีเท่าไร แล้วคุณก็ทำอะไรได้เยอะแล้ว
|
|
|
|
|
Date :
2012-04-12 16:55:06 |
By :
rootElement@kmutnb |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?
$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);
?>
|
|
|
|
|
Date :
2012-04-12 17:13:50 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|