I have used the below code to delete a row in the table and it's not working..
Can anybody help me out
<?php
<input name="delete" type="button" id="delete" value="Delete" onclick="delete()">
<br />
<br />
</label></td>
</tr><?php
$count=mysql_num_rows($qryselect);
echo $count;
// Check if delete button active, start this
function delete(){
echo "working";
for($i=0;$i<$count;$i++){
$del_id = $checkbox[$i];
echo $del_id;
$sql = "DELETE FROM tbl_project WHERE id='$del_id'";
$result = mysql_query($sql);
}
// if successful redirect to delete_multiple.php
if($result){
echo "<meta http-equiv=\"refresh\" content=\"0;URL=delete.php\">";
}
}
?>
Delete a Row in a table
Moderator: General Moderators
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Delete a Row in a table
You can't call a PHP function like that. That's Javascript. PHP is executed on the server before the user gets it: the client cannot see PHP. Instead of a button, make a link that goes to (for example) delete.php?id=[id of the row to delete]. You can access that ID in delete.php with $_GET['id'].