hello... i need help from you all.. i am still new in php.. i hope you all can help me.. i am desperate. i can't delete delete data(delete multiple row from mysql using check box).
this is my coding.. the cooperation is greatly appreciated. i have 2 file
this is my coding
1 file = test1.php
<html>
<HEAD>
<?php session_start(); ?>
<?php
include("db_connect.php"); //connection
mysql_select_db($database_localhost, $conn)or trigger_error(mysql_error(),E_USER_ERROR);
$result=mysql_query("SELECT * FROM cek1a");
?>
<script language=javascript>
function validate()
{
var r=confirm("Adakah anda pasti ingin padam?")
if (r==true)
return true;
else
return false;
}
</script>
</head>
<table bordercolor="#CCCCCC" border='1' cellspacing='1' cellpadding='1'>
<tr>
<form name="test1" method="post" action="test2.php" onSubmit="return validate()">
<tr>
<th bgcolor="#6495ED">NoCek</TH>
<th bgcolor="#6495ED">NAMA </TH>
<th bgcolor="#6495ED">JUMLAH</TH>
<th bgcolor="#6495ED">TUJUAN</TH>
</TR>
<?php
while($row=mysql_fetch_array($result))
{
?>
<tr>
<td align="center"><?php echo $row['noC'];?></td>
<td align="center"><?php echo $row['name'];?></td>
<td align="center"><?php echo $row['jumlah'];?></td>
<td align="center"><?php echo $row['tujuan'];?></td>
<td align="center"><input type="checkbox" name="delete[]" value="<?php echo $row['noC'];?>"></td>
</tr>
<?php
}
?>
<tr>
<td colspan="4">
<CENTER><input type="submit" value="HAPUS"></CENTER>
</td>
</tr>
</form>
</table>
</body>
</html>
second file = test2.php
<?php
include("db_connect.php");
if (isset($_POST['delete']) && is_array($_POST['delete']))
{
foreach ($_POST['delete'] as $num => $value)
{
$sql="delete from cekla where noC='$value'";
$result=mysql_query($sql);
}
}
header("location:test1.php");
?>
i hope you all can help me. :)