Hello everyone.. a newbie programmer here wants to ask why is my codes for deleting rows from my databse won't work.... seems that this codes spread to the net and no one refuse to correct it...
can someone correct this...
[PHP] <!-- Editable Area -->
<?php
include ("../dbconnection/connect.php");
$tbl_name="schedule"; // Table name
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
?>
<?php
while($rows=mysql_fetch_array($result)){
?>
<form name="form1" action="" method="post" enctype="multipart/form-data">
<table id="alter_rows" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center" class="admincheckbox"> <input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"> </td>
<td class="admindate"> <? echo $rows['date']; ?> </td>
<td class="admintime"> <? echo $rows['id']; ?> </td>
<td class="adminevents"> <? echo $rows['events']; ?> </td>
<td class="adminvenue"> <? echo $rows['venue']; ?> </td>
<td class="adminlocations"> <? echo $rows['locations']; ?> </td>
</tr>
</table>
<?php
}
?>
<!-- Editable Area -->
<table cellpadding="0" cellspacing="0">
<tr>
<td><input name="delete" id="delete" type="submit" value="Delete Schedule" /></td>
</tr>
</table>
<?
// Check if delete button active, start this
//$delete = $_REQUEST['delete'];
//
if($delete){
for($i=0;$i<$count;$i++){
$del_id = $checkbox[$i];
$sql = "DELETE FROM schedule WHERE id='$del_id' LIMIT 1";
$result = mysql_query($sql);
}
// if successful redirect to delete_multiple.php
if($result){
echo "<meta http-equiv=\"refresh\" content=\"0;URL=deleterow.php\">";
}
}
mysql_close();
?>
</form>[/PHP]
when a DELETE button hits nothing happens...