Im trying to pass the value of the database table name to another page.
I succesfully display all the database table from my database but the problem is that Im trying to pass it to another page when I click the database table name so that I can get all the values of that table.
<div>
<span class="list-group-item active">
Category
</span>
<ul class="list-group">
<?php
$user = "id6520034_id6520034_shoppingbaguser2";
$password = "travelcompanion17012";
$host = "localhost";
$connection= mysqli_connect($host, $user, $password);
if (!$connection)
{
die ('Could not connect:' . mysqli_error());
}
$showtables= mysqli_query($connection,"SHOW TABLES FROM id6520034_id6520034_shoppingbag2");
while ($row = mysqli_fetch_row($showtables)) {
?>
<a href="./view-all.php?'.$row[productID].'" class="list-group-item">
<span class="badge">14</span>
<?php echo "$row[0]"; ?>
</a>
<?php } ?>
</ul>
</div>
The href link is not working it wont send the value of the database table name to another page.
Hope someone could help me. Thanks!
Well, you have a number of issues in the code.
First is
"SHOW TABLES FROM id6520034_id6520034_shoppingbag2"
will return a list of table names not a key/value pair
Second is as you are using mysqli_fetch_row in your code as follows
while ($row = mysqli_fetch_row($showtables)) {
the $row[0] element will carry the table name. You cannot use a key like $row['productID']
Third is you have mixed php and html here. Also you are missing a parameter name
href="./view-all.php?'.$row[productID].'"
You should rewrite something like
href="./view-all.php?tablename=<?php echo $row[0];?>"