I'm having trouble passing the result of a query into a session variable, I think that the easiest way to do this is through Javascript. I have the query result showing but they will not pass to the session variable. At the end of each query resultant row, I have an add button that will activate the JS function to add to the session variable.

Query Result:

`echo '<tr><td>'.$products['Name'].'</td><td>£'.$products['Price'].'</td><td>'.$products['Category'].'</td><td><img src="'.$products['Image'].'" width=100px /></td><td>'.$products['ProductID'].'</td><td><button onclick="setProduct('.$products['ProductID'].')">Add to Basket</button></td></tr>';`

JS Function:

```
function setProduct(x){

var productID = x;
'<%Session["ProductID"] = "'+$products['productID']+'";%>';

```

Code displaying contents of session variable:

```
echo $_SESSION['ProductID'];

```