Im trying to create a message inbox with a multi delete option. the user selects multiple selectboxes and they will be posted via a submit button. so the post values will be
message[] 1
message[] 2
submit delete
these are the checkboxes that are beeing used:
message id1
<input type='checkbox' id='{inbox_id}' name='message[]' value='{$inbox_id}'/>
message id2
<input type='checkbox' id='{inbox_id}' name='message[]' value='{$inbox_id}'/>
<input class='button' type='submit' value='delete' name='submit'>
This is the code where the post is beeing processed:
else if($_GET['p'] == "del") {
//some user checks
$message_del=$_POST['message'];
$N = count($message_del);
for($i=0; $i < $N; $i++)
{
$result = $db->prepare("UPDATE `messages` SET `outbox`=0 AND `inbox`=0 WHERE `id`= :upid");
$result->bindParam(':upid', $message_del[$i]);
$result->execute();
}
echo "messages archived";
}else{echo "Your TV is lonely"; }
this is the database with 6 messages:
# Name Type Collation Attributes Null Default Extra
1 id int(9) No None AUTO_INCREMENT
2 ip varchar(255)utf8_unicode_ci No
3 time datetime Yes NULL
4 from varchar(16) utf8_unicode_ci Yes NULL
5 to varchar(16) utf8_unicode_ci Yes NULL
6 subject varchar(50) utf8_unicode_ci No
7 message text utf8_unicode_ci No None
8 read int(1) No 0
9 inbox int(1) Yes 1
10 outbox int(1) Yes 1
id ip time from to subject message read inbox outbox
1 00.00.00.00 10-3-2014 19:00 sender receiver subject message 1 1 0
2 00.00.00.00 11-3-2014 19:00 sender receiver subject message 1 1 0
3 00.00.00.00 12-3-2014 19:00 sender receiver subject message 1 1 0
4 00.00.00.00 13-3-2014 19:00 sender receiver subject message 0 1 0
5 00.00.00.00 14-3-2014 19:00 sender receiver subject message 1 0 1
6 00.00.00.00 15-3-2014 19:00 sender receiver subject message 0 0 1
but somehow (i guess) the query doesnt run. i'm afraid i forgot something simple.
This is the single-table syntax of UPDATE :
UPDATE [LOW_PRIORITY] [IGNORE] table_reference
SET col_name1={expr1|DEFAULT} [, col_name2={expr2|DEFAULT}] ...
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count]
When you say SET outbox=0 AND inbox=0
, that is still valid syntax, but does something different than what you probably expect.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.