I have a mysql table where there is no primary key, nothing like 'ID' or so. . I want to delete multiple records in this table using checkboxes ..
can it be possible....???
Delete Multiple Records
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Hmmm
Well. . you can't help going by rules so i created unique ID column in the table. . . i did infact everything ele required .. .now. . still it's not deleting multiple records . . i'm using chekboxes to select the records . .and submitting to other php called delete.php .. .but it's not deleting multiple records .. it deletes the last one in selected records.
any suggestion . .??
any suggestion . .??
- Heavy
- Forum Contributor
- Posts: 478
- Joined: Sun Sep 22, 2002 7:36 am
- Location: Viksjöfors, Hälsingland, Sweden
- Contact:
Your question involves to many unknown factors to answer. Tell us some more.
How does the record selection form look like (HTML with checkboxes)?
What distinguishes one record from another among your checkboxes?
How is the database table designed, what things are PRIMARY or UNIQUE?
How do you build the query to delete the records?
Any error messages?
How does the record selection form look like (HTML with checkboxes)?
What distinguishes one record from another among your checkboxes?
How is the database table designed, what things are PRIMARY or UNIQUE?
How do you build the query to delete the records?
Any error messages?
Still Lost !! :(
Hi Jplush,
Sorry for replying late.. I was out of town..
Back and still lost about multiple delete problem...
..sad
I tried creating array as you said but in vain ..
not ur fault. . it's my dumbness for not udnerstanding foreach() stuff..
basically I'm using Macromedia Dreamweaver MX for site creation and do some coding myself (as and when required)...
Posting below is Code Dreamweaver generated for Deleting Record..
( It can delete one record at a time ) ..
I hope i'm not expecting too much. . but you gyus are great hope for us amatuers ...
Thanks Again.
Sorry for replying late.. I was out of town..
Back and still lost about multiple delete problem...
I tried creating array as you said but in vain ..
not ur fault. . it's my dumbness for not udnerstanding foreach() stuff..
basically I'm using Macromedia Dreamweaver MX for site creation and do some coding myself (as and when required)...
Posting below is Code Dreamweaver generated for Deleting Record..
( It can delete one record at a time ) ..
Code: Select all
<?
$table = $_GET['page'];
$goto = $page.".php";
?>
<?php require_once('../Connections/connpv.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
if ((isset($HTTP_POST_VARS['delbox'])) && ($HTTP_POST_VARS['delbox'] != "")) {
$deleteSQL = sprintf("DELETE FROM $table WHERE rid=%s",
GetSQLValueString($HTTP_POST_VARS['delbox'], "int"));
mysql_select_db($database_connpv, $connpv);
$Result1 = mysql_query($deleteSQL, $connpv) or die(mysql_error());
}
?>Thanks Again.