inserting selected row mysql
I would like to use the row that I have selected and echoed to insert to a
table again. So what I want is row to_user. how should I define $to_user
to get to_user row?
$to_user = $row['to_user'];
$stmt = $mydb->prepare("insert into `messages`(`to_user`) values(?)");
echo $mydb->error;
$stmt->bind_param('s', $to_user);
$stmt->execute();
$stmt = $mydb->prepare("SELECT * FROM messages where id = ? ");
$stmt->bind_param('s', $id);
$stmt->execute();
$result = $stmt->get_result();
while ($row = $result->fetch_assoc()) {
echo $row['to_user'];}
No comments:
Post a Comment