I have this code, I need to set session onclick with tag <a>
using get request on another page.
For example, if I click item 4 it to send the value to URL and set session onclick link.
while(list($product_id,$product_title,$product_name) = mysqli_fetch_row($result)){
echo "<tr>";
echo "<td>".$product_id."</td>";
echo "<td><a href='product_detail.php?sendVar=".$product_id."' onclick='".$_SESSION['kuy'] = $product_id."'>".$product_title."</a></td>";
echo "<td>".$product_name."</td>";
echo "</tr>";
}
Sorry i'm not good at english
答案 0 :(得分:0)
onclick
事件仅适用于浏览器中的javascript
在您的代码中,您为循环中的每个项重写kuy
会话。呈现网页时,您可以找到kuy
product_id
如果您想使用product_id
设置会话,则应在product_detail.php
中执行此操作
您可以在此处从product_id
抓取$_GET['sendVar']
并将此值设置为$_SESSION['kuy']