im trying to pass a session between 2 div on the same page. i have links, when i click on one i want the id to pass to the other div to populate it with the info from the link, but it doesnt pass!!
this is the code from my links div
$q =mysqli_query($link, "SELECT * FROM products WHERE status = 1 ORDER BY id DESC");
while($row = mysqli_fetch_array($q)){
$data = $row['image'];
$file = substr($data, strpos($data, "/") + 1);
$_SESSION['id']=$row['id'];
echo"<div class='homedogs'>",
"<a href='merchandise.php' class='productchoice'>",
"<img class='nailthumb-container3' src='$file' alt='{$row['name']}. Image' />",
"</a>",
"<br />",
'NAME: ',$row['name'],"<br />",'PRICE: ',$row['price'],
"</div>";
}
}
and this is other div that i want to use the session in
include 'inc/connect.php';
$q = mysqli_query($link, "SELECT * FROM products WHERE id = '".$_SESSION['id']."'") or
die (mysql_error());
while($row = mysqli_fetch_array($q)){
$data = $row['image'];
$file = substr($data, strpos($data, "/") + 1);
echo"<div class='rehomediv'>",
"<img class='nailthumb-container2' src='$file' alt='{$row['name']}. Image' />","<br
/>",
"<div class='nameagesex'>",
"<div class='item_name'>{$row['name']}</div>",
"<br />",
"<span class='item_price'>{$row['price']}</span>",
"</div>",
"<div class='description'>",
nl2br($row['description']),
"</div>",
</div>;
im sure its simple enought but i cant get it! can anyone help? thanks
EDIT!!!!!
on page load, pid is not set so i get an error, is there anyway to have it that if pid is not set then it just display the last record?
for anyone confused by this edit, check the accepted answer..