I have a code that uses $_GET to get [id], id is the number of the page I'm calling to.
So, I have a list of pages (loaded from MySQLi), I've been following a tutorial and what is supposed to happen is: When a post in the post list is clicked, the Title, Label and Body textboxes fill up with the content that's inside that post.
This is my code:
<?php if(isset($_GET['id']))
{
$q= "SELECT * FROM pages WHERE id = $_GET[id]";
$r= mysqli_query($mysql, $q);
}
$opened = mysqli_fetch_assoc($r);
?>
It gives an error Undefined Variable: opened. The official mod on GitHub (the mod for the project I'm basing my work on) gave me this code:
<?php
if(isset($_GET['id'])&&is_numeric($_GET['id'])){
$q= "SELECT * FROM pages WHERE id = $_GET[id]";
$r= mysqli_query($mysql, $q);
$opened = mysqli_fetch_assoc($r);
}else{
$opened = null;
}
?>
But when I use it I get blank fields, nothing fills up.
Help please?