my database didn't update
<?php
$db = new mysqli('localhost', 'root', 'root', 'chatting');
$query = "SELECT * FROM user WHERE state = 1 AND getp = 0";
$result = $db->query($query);
$num_result = $result->num_rows;
$mems = "";
for ($i = 0; $i < $num_result; $i++) {
$row = $result->fetch_assoc();
$mems = $row["userName"] . " " . $mems;
$query = "update `user` set `getp` = 1 where 'userName` = ".'
$row["userName"] ';
$result = $db->prepare($query);
}
echo $mems;
?>
what I want I want to get all records that state = 1 and getp = 0, then
inside loop and for every record I want to change the value of getp to 1,
It's correct but don't know where is the wrong, Sorry for my bad english
No comments:
Post a Comment