[PHP-DB] deleting records using a checkbox

2003-03-18 Thread Mark
hello
i have been trying to delete items from a guestbook using multiple checkbox
fields but have had no success

this is the code i have been using to add the checkbox's to the records:

while ($rows = mysql_fetch_array($result)) {

?///?
? //TABLE TO SHOW THE CONTENTS OF USER_MESSAGE DATABASE TABLE ?
?///?

HTML
HEAD
TITLEQueen Vic Message Book/TITLE
/HEAD
BODY

PTABLE BORDER=1 WIDTH=600 BORDERCOLOR=#F0

TR
bDate/Time Posted:/b ? echo $orgdate; ?
/TR

TR
TDbName:/b ? echo $rows['name']; ?/TD

TDbEmail:/b  A HREF=mailto:? echo $rows['email']; ?
   ? echo $rows['email']; ?/TR/TD



TRTD COLSPAN=4
? echo $rows['message']; ?
/TD/TR
/TABLE
TD
bDelete Message/b INPUT TYPE=CHECKBOX NAME=DELETE VALUE=Y
/TD
/P
/BODY
/HTML

?/?
? CLOSES LOOP CREATED FOR ADDING DATA TO TABLE?
?/?
? } ?

this does add a checkbox to every record in the guestbook

how do i link the checkbox to each message id (which are auto incremented)
and then pass some code to delete every checked item??

please help me



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] deleting records

2002-04-07 Thread John Hughes

This was, of course, an example where the PHP code was introducing an error.
The delete sql works as expected and deletes all matching email.

Next time I'm going to sleep on a problem before posting.

- Original Message -
From: John Hughes [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Sunday, April 07, 2002 12:51 AM
Subject: [PHP-DB] deleting records


 It's late and I'm getting groggy.

 I have a table called mail_list.  There are four possible list_names.

 I want to be able to either delete an email associated with a particular
 list or all matching email.

 Deleting WHERE email AND list match works fine.  The problem is when I
want
 to delete an address from all of the lists.

 First I check the database to see how many matches I have.

 $check_sql = 
 SELECT list_id, email FROM mail_list
 WHERE email = '$this_email'
 ;

 For purposes of discussion, we'll say the answer was 3.

 I use this sql when I want to delete all of the email addresses:

 $remove_sql = 
 DELETE FROM mail_list
 WHERE
 email ='$this_email'
 ;

 Only the first record is deleted even though the check_sql found more than
 one match.

 Why doesn't the delete get all of the email addresses that match the first
 time?




 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php





-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] deleting records

2002-04-06 Thread John Hughes

It's late and I'm getting groggy.

I have a table called mail_list.  There are four possible list_names.

I want to be able to either delete an email associated with a particular
list or all matching email.

Deleting WHERE email AND list match works fine.  The problem is when I want
to delete an address from all of the lists.

First I check the database to see how many matches I have.

$check_sql = 
SELECT list_id, email FROM mail_list
WHERE email = '$this_email'
;

For purposes of discussion, we'll say the answer was 3.

I use this sql when I want to delete all of the email addresses:

$remove_sql = 
DELETE FROM mail_list
WHERE
email ='$this_email'
;

Only the first record is deleted even though the check_sql found more than
one match.

Why doesn't the delete get all of the email addresses that match the first
time?




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] Deleting records...

2002-02-20 Thread jas

Ok I am trying to delete records from a database using an html form.  I have
2 files, file one = remove.php3 which queries the database table and
displays the current contents.  Code is as follows.
?php
require '../scripts/db.php';
$result = mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could not
execute query, please try again later);
echo table border=\0\ class=\table-body\ width=\100%\form
name=\rem_inv\ method=\post\ action=\done2.php3\
trtd align=\center\ colspan=\3\font size=\4\BCurrent
Inventory/B/fonthr color=\33\/td/tr;
$count = -1;
while ($myrow = mysql_fetch_row($result)) {
$count ++;
echo trtd width=\30%\BType Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_type));
echo /tdtdinput type=\checkbox\ name=\cars\
value=\checkbox\remove/td
/tr\n;
echo trtd width=\30%\BModel Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_model));
echo /td/tr\n;
echo trtd width=\30%\BYear Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_year));
echo /td/tr\n;
echo trtd width=\30%\BPrice Of Car: /B/tdtd$;
printf(mysql_result($result,$count,car_price));
echo /td/tr\n;
echo trtd width=\30%\BVIN Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_vin));
echo /td/trtrtd colspan=\3\hr color=\33\/td/tr\n;
}
echo trtdinput type=\submit\ name=\delete\
value=\delete\/td/tr/form/table;
?
Once it queries the database it gives the user an option to check the
checkbox and delete that record.  Here is the done2.php3 page that actually
contains the delete sql statement
$db_name = test;
$table_name = inventory;
$connection = @mysql_connect(localhost, root, password) or die (Could
not connect to database.  Please try again later.);
$db = @mysql_select_db($db_name,$connection) or die (Could not select
database table. Please try again later.);
$sql = DELETE FROM $table_name WHERE $cars =
\$car_type\,\$car_model\,\$car_year\,\$car_price\,\$car_vin\,\$dl
r_num\);
$result = @mysql_query($sql, $connection) or die (Could not execute query.
Please try again later.);



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php