|
|
|
แก้ชื่อตัวแปรไป แล้ว Text Box ไม่แสดง ต้องไปดูส่วนไหนคับ ? |
|
|
|
|
|
|
|
สร้างก่อนครับ
|
|
|
|
|
Date :
2012-09-12 10:47:03 |
By :
Dragons_first |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
สร้างยังไงอ่ะคับ
|
|
|
|
|
Date :
2012-09-12 11:39:21 |
By :
ปลาวาฬทราย |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
สร้างไปแล้ว แต่มันยัง error อยู่อ่ะคับ ?
|
|
|
|
|
Date :
2012-09-13 10:14:39 |
By :
ปลาวาฬทราย |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
username : password ที่ใช้ไม่ถูกต้องหรือเปล่า
|
|
|
|
|
Date :
2012-09-13 10:29:11 |
By :
apisitp |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
ถ้า username, password ผิด มันต้องขึ้น Error Connect to Database ไม่ใช่เหรอคับ ?
|
|
|
|
|
Date :
2012-09-14 08:41:48 |
By :
ปลาวาฬทราย |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ชื่อตารางไม่ตรงกันอะป่าว
SELECT * FROM customer
แต่จากภาพตารางชื่อ ipwan มันเลยไม่เจอตาราง customer
|
|
|
|
|
Date :
2012-09-14 09:45:09 |
By :
Baitong_ch |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
13 $strSQL = "INSERT INTO ipwan ";
32 $strSQL = "UPDATE ipwan SET ";
52 $strSQL = "DELETE FROM ipwan ";
63$strSQL = "SELECT * FROM ipwan";
อื่อ ผมเปลี่ยนเป็น ipwan หมดแล้วอ่ะคับ มันก็ขึ้น
Error Query [SELECT * FROM ipwan]
แหละคับ
|
ประวัติการแก้ไข 2012-09-14 10:51:34
|
|
|
|
Date :
2012-09-14 10:48:07 |
By :
ปลาวาฬทราย |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองเอาโค้ดทั้งหมดมาให้ดูหน่อยสิค่ะ
|
|
|
|
|
Date :
2012-09-14 10:50:13 |
By :
Baitong_ch |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตามนี้เลยคับ
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");
//*** Add Condition ***//
if($_POST["hdnCmd"] == "Add")
{
$strSQL = "INSERT INTO ipwan ";
$strSQL .="(CustomerID,Name,Email,CountryCode,Budget,Used) ";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["txtAddCustomerID"]."','".$_POST["txtAddName"]."' ";
$strSQL .=",'".$_POST["txtAddEmail"]."' ";
$strSQL .=",'".$_POST["txtAddCountryCode"]."','".$_POST["txtAddBudget"]."' ";
$strSQL .=",'".$_POST["txtAddUsed"]."') ";
$objQuery = mysql_query($strSQL);
if(!$objQuery)
{
echo "Error Save [".mysql_error()."]";
}
//header("location:$_SERVER[PHP_SELF]");
//exit();
}
//*** Update Condition ***//
if($_POST["hdnCmd"] == "Update")
{
$strSQL = "UPDATE ipwan SET ";
$strSQL .="CustomerID = '".$_POST["txtEditCustomerID"]."' ";
$strSQL .=",Name = '".$_POST["txtEditName"]."' ";
$strSQL .=",Email = '".$_POST["txtEditEmail"]."' ";
$strSQL .=",CountryCode = '".$_POST["txtEditCountryCode"]."' ";
$strSQL .=",Budget = '".$_POST["txtEditBudget"]."' ";
$strSQL .=",Used = '".$_POST["txtEditUsed"]."' ";
$strSQL .="WHERE CustomerID = '".$_POST["hdnEditCustomerID"]."' ";
$objQuery = mysql_query($strSQL);
if(!$objQuery)
{
echo "Error Update [".mysql_error()."]";
}
//header("location:$_SERVER[PHP_SELF]");
//exit();
}
//*** Delete Condition ***//
if($_GET["Action"] == "Del")
{
$strSQL = "DELETE FROM ipwan ";
$strSQL .="WHERE CustomerID = '".$_GET["CusID"]."' ";
$objQuery = mysql_query($strSQL);
if(!$objQuery)
{
echo "Error Delete [".mysql_error()."]";
}
//header("location:$_SERVER[PHP_SELF]");
//exit();
}
$strSQL = "SELECT * FROM ipwan";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<form name="frmMain" method="post" action="<?=$_SERVER["PHP_SELF"];?>">
<input type="hidden" name="hdnCmd" value="">
<table width="600" border="1">
<tr>
<th width="91"> <div align="center">CustomerID </div></th>
<th width="98"> <div align="center">Name </div></th>
<th width="198"> <div align="center">Email </div></th>
<th width="97"> <div align="center">CountryCode </div></th>
<th width="59"> <div align="center">Budget </div></th>
<th width="71"> <div align="center">Used </div></th>
<th width="30"> <div align="center">Edit </div></th>
<th width="30"> <div align="center">Delete </div></th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<?
if($objResult["CustomerID"] == $_GET["CusID"] and $_GET["Action"] == "Edit")
{
?>
<tr>
<td><div align="center">
<input type="text" name="txtEditCustomerID" size="5" value="<?=$objResult["CustomerID"];?>">
<input type="hidden" name="hdnEditCustomerID" size="5" value="<?=$objResult["CustomerID"];?>">
</div></td>
<td><input type="text" name="txtEditName" size="20" value="<?=$objResult["Name"];?>"></td>
<td><input type="text" name="txtEditEmail" size="20" value="<?=$objResult["Email"];?>"></td>
<td><div align="center"><input type="text" name="txtEditCountryCode" size="2" value="<?=$objResult["CountryCode"];?>"></div></td>
<td align="right"><input type="text" name="txtEditBudget" size="5" value="<?=$objResult["Budget"];?>"></td>
<td align="right"><input type="text" name="txtEditUsed" size="5" value="<?=$objResult["Used"];?>"></td>
<td colspan="2" align="right"><div align="center">
<input name="btnAdd" type="button" id="btnUpdate" value="Update" OnClick="frmMain.hdnCmd.value='Update';frmMain.submit();">
<input name="btnAdd" type="button" id="btnCancel" value="Cancel" OnClick="window.location='<?=$_SERVER["PHP_SELF"];?>';">
</div></td>
</tr>
<?
}
else
{
?>
<tr>
<td><div align="center"><?=$objResult["CustomerID"];?></div></td>
<td><?=$objResult["Name"];?></td>
<td><?=$objResult["Email"];?></td>
<td><div align="center"><?=$objResult["CountryCode"];?></div></td>
<td align="right"><?=$objResult["Budget"];?></td>
<td align="right"><?=$objResult["Used"];?></td>
<td align="center"><a href="<?=$_SERVER["PHP_SELF"];?>?Action=Edit&CusID=<?=$objResult["CustomerID"];?>">Edit</a></td>
<td align="center"><a href="JavaScript:if(confirm('Confirm Delete?')==true){window.location='<?=$_SERVER["PHP_SELF"];?>?Action=Del&CusID=<?=$objResult["CustomerID"];?>';}">Delete</a></td>
</tr>
<?
}
?>
<?
}
?>
<tr>
<td><div align="center"><input type="text" name="txtAddCustomerID" size="5"></div></td>
<td><input type="text" name="txtAddName" size="20"></td>
<td><input type="text" name="txtAddEmail" size="20"></td>
<td><div align="center"><input type="text" name="txtAddCountryCode" size="2"></div></td>
<td align="right"><input type="text" name="txtAddBudget" size="5"></td>
<td align="right"><input type="text" name="txtAddUsed" size="5"></td>
<td colspan="2" align="right"><div align="center">
<input name="btnAdd" type="button" id="btnAdd" value="Add" OnClick="frmMain.hdnCmd.value='Add';frmMain.submit();">
</div></td>
</tr>
</table>
</form>
<?
mysql_close($objConnect);
?>
</body>
</html>
|
|
|
|
|
Date :
2012-09-14 10:54:17 |
By :
ปลาวาฬทราย |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ผิดตรง เลือกฐานข้อมูลค่ะ
$objDB = mysql_select_db("mydatabase"); ต้องเลือกฐานข้อมูลของเราคือ $objDB = mysql_select_db("ipwan");
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("ipwan");
//*** Add Condition ***//
if($_POST["hdnCmd"] == "Add")
{
$strSQL = "INSERT INTO ipwan ";
$strSQL .="(CustomerID,Name,Email,CountryCode,Budget,Used) ";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["txtAddCustomerID"]."','".$_POST["txtAddName"]."' ";
$strSQL .=",'".$_POST["txtAddEmail"]."' ";
$strSQL .=",'".$_POST["txtAddCountryCode"]."','".$_POST["txtAddBudget"]."' ";
$strSQL .=",'".$_POST["txtAddUsed"]."') ";
$objQuery = mysql_query($strSQL);
if(!$objQuery)
{
echo "Error Save [".mysql_error()."]";
}
//header("location:$_SERVER[PHP_SELF]");
//exit();
}
//*** Update Condition ***//
if($_POST["hdnCmd"] == "Update")
{
$strSQL = "UPDATE ipwan SET ";
$strSQL .="CustomerID = '".$_POST["txtEditCustomerID"]."' ";
$strSQL .=",Name = '".$_POST["txtEditName"]."' ";
$strSQL .=",Email = '".$_POST["txtEditEmail"]."' ";
$strSQL .=",CountryCode = '".$_POST["txtEditCountryCode"]."' ";
$strSQL .=",Budget = '".$_POST["txtEditBudget"]."' ";
$strSQL .=",Used = '".$_POST["txtEditUsed"]."' ";
$strSQL .="WHERE CustomerID = '".$_POST["hdnEditCustomerID"]."' ";
$objQuery = mysql_query($strSQL);
if(!$objQuery)
{
echo "Error Update [".mysql_error()."]";
}
//header("location:$_SERVER[PHP_SELF]");
//exit();
}
//*** Delete Condition ***//
if($_GET["Action"] == "Del")
{
$strSQL = "DELETE FROM ipwan ";
$strSQL .="WHERE CustomerID = '".$_GET["CusID"]."' ";
$objQuery = mysql_query($strSQL);
if(!$objQuery)
{
echo "Error Delete [".mysql_error()."]";
}
//header("location:$_SERVER[PHP_SELF]");
//exit();
}
$strSQL = "SELECT * FROM ipwan";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<form name="frmMain" method="post" action="<?=$_SERVER["PHP_SELF"];?>">
<input type="hidden" name="hdnCmd" value="">
<table width="600" border="1">
<tr>
<th width="91"> <div align="center">CustomerID </div></th>
<th width="98"> <div align="center">Name </div></th>
<th width="198"> <div align="center">Email </div></th>
<th width="97"> <div align="center">CountryCode </div></th>
<th width="59"> <div align="center">Budget </div></th>
<th width="71"> <div align="center">Used </div></th>
<th width="30"> <div align="center">Edit </div></th>
<th width="30"> <div align="center">Delete </div></th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<?
if($objResult["CustomerID"] == $_GET["CusID"] and $_GET["Action"] == "Edit")
{
?>
<tr>
<td><div align="center">
<input type="text" name="txtEditCustomerID" size="5" value="<?=$objResult["CustomerID"];?>">
<input type="hidden" name="hdnEditCustomerID" size="5" value="<?=$objResult["CustomerID"];?>">
</div></td>
<td><input type="text" name="txtEditName" size="20" value="<?=$objResult["Name"];?>"></td>
<td><input type="text" name="txtEditEmail" size="20" value="<?=$objResult["Email"];?>"></td>
<td><div align="center"><input type="text" name="txtEditCountryCode" size="2" value="<?=$objResult["CountryCode"];?>"></div></td>
<td align="right"><input type="text" name="txtEditBudget" size="5" value="<?=$objResult["Budget"];?>"></td>
<td align="right"><input type="text" name="txtEditUsed" size="5" value="<?=$objResult["Used"];?>"></td>
<td colspan="2" align="right"><div align="center">
<input name="btnAdd" type="button" id="btnUpdate" value="Update" OnClick="frmMain.hdnCmd.value='Update';frmMain.submit();">
<input name="btnAdd" type="button" id="btnCancel" value="Cancel" OnClick="window.location='<?=$_SERVER["PHP_SELF"];?>';">
</div></td>
</tr>
<?
}
else
{
?>
<tr>
<td><div align="center"><?=$objResult["CustomerID"];?></div></td>
<td><?=$objResult["Name"];?></td>
<td><?=$objResult["Email"];?></td>
<td><div align="center"><?=$objResult["CountryCode"];?></div></td>
<td align="right"><?=$objResult["Budget"];?></td>
<td align="right"><?=$objResult["Used"];?></td>
<td align="center"><a href="<?=$_SERVER["PHP_SELF"];?>?Action=Edit&CusID=<?=$objResult["CustomerID"];?>">Edit</a></td>
<td align="center"><a href="JavaScript:if(confirm('Confirm Delete?')==true){window.location='<?=$_SERVER["PHP_SELF"];?>?Action=Del&CusID=<?=$objResult["CustomerID"];?>';}">Delete</a></td>
</tr>
<?
}
?>
<?
}
?>
<tr>
<td><div align="center"><input type="text" name="txtAddCustomerID" size="5"></div></td>
<td><input type="text" name="txtAddName" size="20"></td>
<td><input type="text" name="txtAddEmail" size="20"></td>
<td><div align="center"><input type="text" name="txtAddCountryCode" size="2"></div></td>
<td align="right"><input type="text" name="txtAddBudget" size="5"></td>
<td align="right"><input type="text" name="txtAddUsed" size="5"></td>
<td colspan="2" align="right"><div align="center">
<input name="btnAdd" type="button" id="btnAdd" value="Add" OnClick="frmMain.hdnCmd.value='Add';frmMain.submit();">
</div></td>
</tr>
</table>
</form>
<?
mysql_close($objConnect);
?>
</body>
</html>
|
|
|
|
|
Date :
2012-09-14 11:16:51 |
By :
Baitong_ch |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ทำได้ยังครับ อิอิ
เผื่อไม่ได้
เพิ่มข้อมูลลงไปในฐานข้อมูลก่อนครับ สัก 1 ก็ได้
|
ประวัติการแก้ไข 2012-09-14 11:35:25
|
|
|
|
Date :
2012-09-14 11:26:01 |
By :
icman |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mydatabase
|
|
|
|
|
Date :
2012-09-14 13:34:20 |
By :
apisitp |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เปลี่ยน mydatabase เป็น ipwan ใช้ได้แล้วคับ ขอบคุณมากคับ
|
|
|
|
|
Date :
2012-09-14 18:06:23 |
By :
ปลาวาฬทราย |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แก้ชื่อตัวแปรไป แล้ว Text Box ไม่แสดง ต้องไปดูส่วนไหนคับ ?
|
|
|
|
|
Date :
2012-09-17 15:43:21 |
By :
ปลาวาฬทราย |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date :
2012-09-24 12:10:34 |
By :
ปลาวาฬทราย |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|