|
|
|
สอบถามผู้รู้ครับ อยากได้สคริบ delete record รบกวนแนะนำด้วยครับ |
|
|
|
|
|
|
|
Code (PHP)
<td align="center"><a href="phpMySQLDeleteRecord.php?CusID=<?php echo $objResult["CustomerID"];?>">Delete</a></td>
Code (PHP)
<?php
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "DELETE FROM customer ";
$strSQL .="WHERE CustomerID = '".$_GET["CusID"]."' ";
$objQuery = mysql_query($strSQL);
if($objQuery)
{
echo "Record Deleted.";
}
else
{
echo "Error Delete [".$strSQL."]";
}
mysql_close($objConnect);
?>
PHP MySQL Delete Record/Confirm Delete
|
|
|
|
|
Date :
2015-11-11 17:18:36 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
อยากให้มันลบแค่ค่าที่ดึงมาใน textbox เฉยๆครับไม่ได้ลบใน database นะครับ
|
|
|
|
|
Date :
2015-11-12 09:31:26 |
By :
Assadawut |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ใช้ jquery .remove คับกดปุ่มละ ลบ ออกไป แต่เวลา refresh ก็จะกลับมาอีกที
Code (PHP)
<table>
<tr id="row<?php echo $row['code'];?>">
<td>TA001</td>
<td><button type="button" onclick="$('#row+'<?php echo $row['code'];?>).remove()">ปุ่มลบ</button></td>
</tr>
<tr id="row<?php echo $row['code'];?>">
<td>TA002</td>
<td><button type="button" onclick="$('#row+'<?php echo $row['code'];?>).remove()">ปุ่มลบ</button></td>
</tr>
หลักการประมาณนี้คับ
|
|
|
|
|
Date :
2015-11-12 21:09:20 |
By :
progamer2000 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ThaiCreate.Com PHP & MySQL Tutorial</title>
<style type="text/css">
body,td,th {
color: #666;
}
</style>
<style>
p {
background: yellow;
margin: 6px 0;
}
</style>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<table width="100%" >
<tr>
<td height="49" align="left" bgcolor="#0000FF"><center>
<h3><center>
<h3 style="color: #FFF">ใบแจ้งขอทำโอทีล่วงหน้า<br />
OVERTIME WORKING REQUEST FROM</h3>
</center></h3>
</td>
</tr>
</table>
<div style="background-color:#FFFFFF" align="center">
<form name="frmMain" action="PageMultiCheckbox2.php" method="post" OnSubmit="return onSave();">
<?
$strSearch = $_POST["txtSearch"];
$objConnect = mysql_connect("localhost","root","mb,lNwmp") or die("Error Connect to Database");
$objDB = mysql_select_db("hr");
mysql_query("SET NAMES UTF8");
$strSQL = "SELECT * FROM employee WHERE (Code LIKE '%".$strSearch."%' or Section LIKE '%".$strSearch."%' )";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="600" id="tbExp">
<tr>
<th width="10" nowrap="nowrap" bgcolor="#FFCC00" style="font-size: 12px"> <div align="center">รหัสพนักงาน<br />
ID </div></th>
<th width="98" nowrap="nowrap" bgcolor="#FFCC00" style="font-size: 12px"> <div align="center">ชื่อพนักงาน<br />
EMPLOYEE NAME </div></th>
<th width="80" nowrap="nowrap" bgcolor="#FFCC00" style="font-size: 12px"> <div align="center">ตำแหน่ง<br />
POSITION TITLE</div></th>
<th width="59" nowrap="nowrap" bgcolor="#FFCC00" style="font-size: 12px"> <div align="center">วันที่<br />
DATE </div></th>
</tr>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
$i++;
?>
<tr id="row<?php echo $row['Name_th'];?>">
<td nowrap="nowrap"><div align="center"><input type="text" name="txtCode<?php echo $objResult["Code"];?>" value="<?php echo $objResult["Code"];?>" size="10" readonly></div></td>
<td nowrap="nowrap"><input type="text" name="txtName_th<?php echo $i;?>" value="<?php echo $objResult["Name_th"];?>" size="30" readonly></td>
<td nowrap="nowrap"><input type="text" name="txtPosition<?php echo $i;?>" value="<?php echo $objResult["Position"];?>" size="20" readonly></td>
<td nowrap="nowrap"><input name="txtdate<?php echo $i;?>" type="text" id="txtdate" value="<?php echo date("Y/m/d"); ?>" size="7" readonly></td>
<td nowrap="nowrap"><button type="button" onclick="$('#row'<?php echo $row['Name_th'];?>).remove()">-</button></td>
</tr>
<?
}
?>
</table>
<?
mysql_close($objConnect);
?>
<input type="submit" name="btnSave" value="Save">
<input type="hidden" name="hdnCount" value="<?php echo $i;?>">
</form>
</div>
</body>
</html>
ติดปัญหาไม่ยอมลบ record ที่เลือกครับต้องแก้ไขโค้ดตรงไหนครับ
|
ประวัติการแก้ไข 2015-11-13 09:09:30
|
|
|
|
Date :
2015-11-13 09:08:44 |
By :
Assadawut |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ผมเทสละก็ได้นะคับ
Code (PHP)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ThaiCreate.Com PHP & MySQL Tutorial</title>
<style type="text/css">
body,td,th {
color: #666;
}
</style>
<style>
p {
background: yellow;
margin: 6px 0;
}
</style>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<table width="100%" >
<tr>
<td height="49" align="left" bgcolor="#0000FF"><center>
<h3><center>
<h3 style="color: #FFF">ใบแจ้งขอทำโอทีล่วงหน้า<br />
OVERTIME WORKING REQUEST FROM</h3>
</center></h3>
</td>
</tr>
</table>
<div style="background-color:#FFFFFF" align="center">
<form name="frmMain" action="PageMultiCheckbox2.php" method="post" OnSubmit="return onSave();">
<table width="600" id="tbExp">
<tr>
<th width="10" nowrap="nowrap" bgcolor="#FFCC00" style="font-size: 12px"> <div align="center">รหัสพนักงาน<br />
ID </div></th>
<th width="98" nowrap="nowrap" bgcolor="#FFCC00" style="font-size: 12px"> <div align="center">ชื่อพนักงาน<br />
EMPLOYEE NAME </div></th>
<th width="80" nowrap="nowrap" bgcolor="#FFCC00" style="font-size: 12px"> <div align="center">ตำแหน่ง<br />
POSITION TITLE</div></th>
<th width="59" nowrap="nowrap" bgcolor="#FFCC00" style="font-size: 12px"> <div align="center">วันที่<br />
DATE </div></th>
</tr>
</tr>
<tr id="row1">
<td nowrap="nowrap"><div align="center"><input type="text" name="txtCode1" value="1" size="10" readonly></div></td>
<td nowrap="nowrap"><input type="text" name="txtName_th1" value="1" size="30" readonly></td>
<td nowrap="nowrap"><input type="text" name="txtPosition1" value=1" size="20" readonly></td>
<td nowrap="nowrap"><input name="txtdate1" type="text" id="txtdate" value="1" size="7" readonly></td>
<td nowrap="nowrap"><button type="button" onclick="$('#row1').remove()">-</button></td>
</tr>
<tr id="row2">
<td nowrap="nowrap"><div align="center"><input type="text" name="txtCode2" value="2" size="10" readonly></div></td>
<td nowrap="nowrap"><input type="text" name="txtName_th2" value="2" size="30" readonly></td>
<td nowrap="nowrap"><input type="text" name="txtPosition2" value=2" size="20" readonly></td>
<td nowrap="nowrap"><input name="txtdate1" type="text" id="txtdate" value="2" size="7" readonly></td>
<td nowrap="nowrap"><button type="button" onclick="$('#row2').remove()">-</button></td>
</tr>
</table>
<input type="submit" name="btnSave" value="Save">
<!--<input type="hidden" name="hdnCount" value="<?php echo $i;?>">-->
</form>
</div>
</body>
</html>
ตรง id ใช้เป็น รหัสตัวเลขซิครับ มันไม่ซ้ำกัน
|
ประวัติการแก้ไข 2015-11-13 09:48:54
|
|
|
|
Date :
2015-11-13 09:48:13 |
By :
progamer2000 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|