Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > สอบถามเรื่องการลบข้อมูลทีละหลายๆแถว โดยใช้ checkbox



 

สอบถามเรื่องการลบข้อมูลทีละหลายๆแถว โดยใช้ checkbox

 



Topic : 034265



โพสกระทู้ ( 15 )
บทความ ( 0 )



สถานะออฟไลน์




ที่ทำแล้วข้อมูลมันขึ้นนะคะ แต่ทำไมลบไม่ได้ ช่วยดูโค้ดให้หน่อยนะคะ ขอบคุณค่ะ

//delete_q.php

Code (PHP)
<?
include('connect.php');
for($i=0;$i<count($_POST["select"]);$i++)
    {
        if($_POST["select"][$i] != "")
        {
            $sql = "DELETE FROM request ";
            $sql .="WHERE id_request = '".$_POST["select"][$i]."' ";
            $query = mysql_query($sql);
        }
    }
echo "Record Deleted.";
echo "<meta http-equiv='refresh' content='2; url=request_form.php' />";
mysql_close();
?>


.......................................................................


//connect.php

Code (PHP)
<?
$host ="localhost";
$username ="root";
$password ="1234";
$dbname="reliability";

$link = mysql_connect($host,$username,$password)or die ("Cannot connect mysgl");

mysql_select_db($dbname,$link)or die ("Cannot select $dbname");
?>


............................................................................


//request_form.php

Code (PHP)
<? include('connect.php');
$dbquery=mysql_db_query($dbname,$sql);
$sql = "select * from request order by id_request";
$dbquery = mysql_db_query($dbname, $sql);
$query = mysql_query($sql) or die ("Error Query [".$sql."]");
?>
<script language="javascript">
function fncConfirm()
{
	if(confirm('Do you want to delete ?')==true)
	{
		window.location = 'delete_q.php';
	}
}
</script>


 <table border="2" bordercolor="#000000" width="868" >
    <form name="form2"action="delete_q.php" method="post">
    <tr bgcolor="#9969ff" >
    <td><font size ="2" ><center><b><font color="red">Select</font></b></center></font></td>
    <td><font size ="2" ><center><b>Request Date    </b></center></font></td>
    <td><font size ="2" ><center><b>Require Date    </b></center></font></td>
    <td><font size ="2" ><center><b>Product         </b></center></font></td>
    <td><font size ="2" ><center><b>Interface       </b></center></font></td>
    <td><font size ="2" ><center><b>Eval Catalog    </b></center></font></td>
    <td><font size ="2" ><center><b>Detail          </b></center></font></td>
    <td><font size ="2" ><center><b>Test Script     </b></center></font></td>
    <td><font size ="2" ><center><b>EEN             </b></center></font></td>
    <td><font size ="2" ><center><b>Eval Owner      </b></center></font></td>
    <td><font size ="2" ><center><b>Eval Title      </b></center></font></td>
    <td><font size ="2" ><center><b>Q'ty            </b></center></font></td>
    <td><font size ="2" ><center><b>Remark          </b></center></font></td>
    </tr>
    <? 
        while($result = mysql_fetch_array($dbquery))
        {
    ?>
    <tr bgcolor="white" link="#00ff45"><tr></tr>
    
    <td><center><input type="checkbox" name="select[]" value="<?=$Result["id_request"];?>"></center></td>
    <td><font size ="2" ><center><?=$result[date] ?>        </center></font></td>
    <td><font size ="2" ><center><?=$result[require_]?>     </center></font></td>
    <td><font size ="2" ><center><?=$result[product]?>      </center></font></td>
    <td><font size ="2" ><center><?=$result[interface_]?>   </center></font></td>
    <td><font size ="2" ><center><?=$result[eval_catalog]?> </center></font></td>
    <td><font size ="2" ><center><?=$result[detail]?>       </center></font></td>
    <td><font size ="2" ><center><?=$result[test_script]?>	</center></font></td>
    <td><font size ="2" ><center><?=$result[een] ?>         </center></font></td>
    <td><font size ="2" ><center><?=$result[owner]?>        </center></font></td>
    <td><font size ="2" ><center><?=$result[title]?>        </center></font></td>
    <td><font size ="2" ><center><?=$result[q_ty] ?>        </center></font></td>
    <td><font size ="2" ><center><?=$result[remark] ?>      </center></font></td>
    
    <?
        }
            mysql_close();
       ?>
       <tr><td align="right">
        <input name="delete" type="button" value="Delete" OnClick="JavaScript:fncConfirm();" /></td></tr>
    </form>
</table>




Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2009-11-12 11:00:06 By : epuizaa View : 1644 Reply : 3
 

 

No. 1



โพสกระทู้ ( 2,794 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์


Delete_q.php
Code (PHP)
<?
include('connect.php');
for($i=0;$i<count($_POST["select"]);$i++)
{
if($_POST["select"][$i] != "")
{
$sql = "DELETE FROM request ";
$sql .="WHERE id_request = '".$_POST[select][$i]."' ";
$query = mysql_query($sql);
}
}
echo "Record Deleted.";
echo "<meta http-equiv='refresh' content='2; url=request_form.php' />";
mysql_close();
?>







Date : 2009-11-12 11:29:03 By : panyapol
 


 

No. 2



โพสกระทู้ ( 15 )
บทความ ( 0 )



สถานะออฟไลน์


ขอบคุณค่ะ จะลองดูนะคะ
Date : 2009-11-12 14:16:14 By : epuizaa
 

 

No. 3



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

Code (phpMySQLDeleteMultiRecordList.php)
<html>
<head>
<title>ThaiCreate.Com PHP & MySQL Tutorial</title>
</head>
<body>
<script language="JavaScript">
	function onDelete()
	{
		if(confirm('Do you want to delete ?')==true)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
</script>
<form name="frmMain" action="phpMySQLDeleteMultiRecord.php" method="post" OnSubmit="return onDelete();">
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM customer";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<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">Delete </div></th>
  </tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
  <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"><input type="checkbox" name="chkDel[]" value="<?=$objResult["CustomerID"];?>"></td>
  </tr>
<?
}
?>
</table>
<?
mysql_close($objConnect);
?>
<input type="submit" name="btnDelete" value="Delete">
</form>
</body>
</html>


Code (phpMySQLDeleteMultiRecord.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");

	for($i=0;$i<count($_POST["chkDel"]);$i++)
	{
		if($_POST["chkDel"][$i] != "")
		{
			$strSQL = "DELETE FROM customer ";
			$strSQL .="WHERE CustomerID = '".$_POST["chkDel"][$i]."' ";
			$objQuery = mysql_query($strSQL);
		}
	}

	echo "Record Deleted.";

mysql_close($objConnect);
?>
</body>
</html>


Screenshot



Ref : PHP MySQL Multiple Checkbox Delete Record
Date : 2009-11-14 19:22:09 By : webmaster
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : สอบถามเรื่องการลบข้อมูลทีละหลายๆแถว โดยใช้ checkbox
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 00
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่