I have searched for similar questions but every question that was related wasn't the solution for me.
I am using php, sql and phpmyadmin for this.
I'm trying to add characters to a world. The idea is that you can add characters to a world by selecting them in option field(for now) and change the world_id of that character.
Now i have the id but i don't know how to actually change it in the database.
I will show my database
table characters:
id
name
last_name
image
age
world_id (this table is linked with the table worlds)
table worlds:
world_id (so the world_id's are linked
name
description
my php code:
$pdo = Database::connect();
$sql = 'SELECT * FROM characters ORDER BY id DESC';
echo '<select name="option">';
foreach ($pdo->query($sql) as $row) {
echo '<option value="' . $row['id'] . '">' . $row['name'] . '</option>';
}
echo '</select>';
$selected_val = $_POST['option'];
?>
Hopefully can someone help me.