My php While loop run the query, but the results must be print inside html. In this moment I unknow the way to make this:
My php while loop
<?php
include "connect.php";
$username=$_SESSION['Username'];
$result = mysqli_query($dbconn,"
SELECT *
FROM books
WHERE username = '$Username'
");
while($rows = mysqli_fetch_array($result));
?>
After this code there is a Html code where I want print the variables:
<a href="editBook.php?bookid=<?php echo $book_id; ?>&book_name=<?php echo $book_name; ?>">Edit</a>
In this moment the variable is empty
How to fix this?
[Resolved] Update I have resolve my problem. This is the correct php script. Work fine:
<?php
include "connect.php";
$username=$_SESSION['Username'];
$result = mysqli_query($dbconn,"
SELECT *
FROM books
WHERE username = '$Username'
");
global $book_id, $book_name
while($row = mysqli_fetch_array($result)) {
$book_id = row['book_id'];
$book_name = row['book_name'];
?>
Outside while loop. Print variable inside Html:
<?php echo $row['book_id']; ?> <br>
<?php echo $row['book_name']; ?>
Close while loop and connection:
<?php
}
mysqli_close($dbconn);
?>
echo $rows['column_name'];