alex1233213
alex1233213

Reputation: 11

How do I reference an item from database to a link in a php page?

I am doing a reservation page where I have multiple links which redirect to a page where the reservation is made.

The link is displayed multiple times for every book in my database. It is in a while loop.

if(mysqli_num_rows($result_category) > 0) {
            while($row = mysqli_fetch_assoc($result_category)) {
               //... print each book then print the link to reserve
               echo "<a id=\"reservelink\" href=\"viewRes.php?id=". $isbn ."\">Reserve</a><br>";
            }
         } else {
            echo "The chosen category has no books available";
      }

I tried doing the code above for each book href=\"viewRes.php?id=". $isbn ...

But when I try to echo the $isbn on viewRes page it would not be echoed. is there a way to assign each item in the database to a specific $isbn value? Thanks in advance

Upvotes: 1

Views: 110

Answers (1)

Syed Hussim
Syed Hussim

Reputation: 760

Change php?id=". $isbn ." to php?id=". $row['isbn'] ."

Upvotes: 1

Related Questions