sino po marunong mag php/mysql dito? may problem po ako tungkol sa code ko for delete record sa php. sana po may makatulong sakin
di ko po alam kung saan ko po hahatiin yung code para sa method action ng form.
ito po yung code ko:
salamat po sa magrereply!
---------------------------------
<?php
$host="localhost";
$username="root";
$password="";
$db_name="testing";
// Conn
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql="SELECT * FROM poll order by ID asc";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
?>
<html>
<title>Delete Surveys</title>
<body style="margin-top: 100px;">
<table width="400" border="0" cellspacing="1" cellpadding="0" align="center">
<tr>
<td><form name="form1" method="post" action="delete.php">
<table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td bgcolor="#FFFFFF"> </td>
<td colspan="4" bgcolor="#FFFFFF"><strong><center>Delete Surveys</center></strong> </td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF"><b>Delete</b></td>
<td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $rows['id']; ?>"></td>
<td bgcolor="#FFFFFF"><?php echo $rows['id']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $rows['name']; ?></td>
</tr>
<?php
}
?>
<tr>
<td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"> | <a href="admin.php">Back</a></td>
</tr>
<?php
// checkbox validate
if($delete){
for($i=0;$i<$count;$i++){
$del_id = $checkbox[$i];
$sql2 = "DELETE FROM poll WHERE id= '".$rows["id"]."' ";
$result2 = mysql_query($sql2);
}
// if successful redirect to delete_multiple.php
if($result2)
{
echo "<meta http-equiv=\"refresh\" content=\"0;URL=delete_multiple.php\">";
}
}
mysql_close();
?>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>