It is not clear but I believe you should move the $id = $_POST['id']
inside your if
statement
and the code should be:
<?PHP
include "configdb.php";
if (isset($_POST['id']))
{
$id = $_POST['id'];
$sql = "SELECT * FROM `booklist` WHERE `id` = '$id'";
$res = mysqli_query($connect, $sql) or die("Could not update".mysql_error());
$row = mysqli_fetch_row($res);
$id = $row[0];
$title = $row[1];
$author = $row[2];
$ISBN = $row[3];
$category = $row[4];
$image_upload = $row[5];
$image_upload2 = $row[6];
}
?>
EXTRA INFO
If what I believe this question is about getting a book id from a book list, then run a query in db to return the results then a better code will be something like this:
<?PHP
include "configdb.php";
if (isset($_POST['id']))
{
$id = $_POST['id'];
$sql = mysqli_query($connect, "SELECT * FROM booklist WHERE id = $id") or die("Could not update".mysql_error());
$rows = mysqli_num_rows($sql); // get the number of returning rows (0 means no query match found, > 0 means a query match found)
if($rows > 0)
{
while($i = mysqli_fetch_assoc($sql))
{
$book_id = $sql[0];
$book_title = $sql[1];
$author = $sql[2];
$ISBN = $sql[3];
$category = $sql[4];
$image_upload = $sql[5];
$image_upload2 = $sql[6];
// the rest of your code and what you want to do with the result....
}
}
eles // no results found message
{
echo 'Sorry, no results found.';
} // end of else
}
?>
Also please note that you can use the column name instead of $sql[0], $sql[1], $sql[3]
so if your first table columns has a name of book_id
then it can be
$book_id = $sql['book_id'];
instead of $book_id = $sql[0];
. This much easier to deal with when you work in your code so you don't have to go back and fourth to your db to check indexes of columns. also, it will help you a lot when you update your code or share it with others.