Hello,
I am trying to the print the variables from the URL. I have tried some methods but it is working. There are variables in the URL. it is just I am not able to print them out.
<?php
if(isset($_SESSION['cart'])){
echo '<ol>';
foreach ($_GET as $name => $value)
{
echo $key . " : " . $value . "<br />\r\n";
}
echo '</ol>';
}else{
echo 'Your Cart is empty';
}
?>
This is where I am trying to print them out
Below is the code from where the products are retrieved from the database and the variables are added to the URL
<?php
require "connect.php";
$query = "SELECT `DVDID`, `NameOfTheDVD`, `Quantity` FROM `DVD`";
$stmt = $dbhandle->prepare($query);
$stmt->execute();
$num = $stmt->rowCount();
if($num>0){
while ($row = $stmt->fetch(PDO::FETCH_OBJ)){
if(!isset($_SESSION['cart'])){
echo "<table border='3' cellpadding='10' position='relative` bottom= '450px';>";//start table
echo '<tr>';
echo '<div class="DVD ID">';
echo 'DVD Id : '.$row->DVDID.'<br>';
$mydvd = $row->DVDID;
$name = $row->NameOfTheDVD;
echo 'Name Of the DVD : '.$row->NameOfTheDVD.'<br>';
echo 'Quantity : '.$row->Quantity.' ';
echo '<form method="post" action="basket.php?'.$mydvd . $name. '">';
echo '<input type="hidden" name="id" value="DVDID">';
echo '<input type="hidden" name="item" value="NameOfTheDVD">';
echo '<input type="hidden" name="Quantity" value="Quantity">';
echo '<input type="submit" value="Add To Basket">';
echo '</tr>';
}
}
echo "</table>";
}
// no products in the database
else{
echo "No products found.";
}
?>
ANY HELP WOULD BE APPRECIATED. THANK YOU