Passing of session variables

0 replies
i wanted to query a database using some keywords, thereafter when a matched result is click, the variable of the clicked item can be passed on to the next page and this variable is use to query the database for the last time to output the details of the item.


here is what i have written so far,
on search.php

$findi = mysqli_query($grant,"select * from $table")or die(mysqli_error($findi));
$count=1;
while($row = mysqli_fetch_array($findi)
{
//session variables
$under = $_SESSION['prop']= $row['name'];
$_SESSION['state']=$row['state'];
$_SESSION['city']=$row['city'];
$_SESSION['description']=$row['description'];
$_SESSION['offer']=$row['offer'];
$_SESSION['id']=$row['id'];


$_SESSION['path']=$src=$file_path.$row['photo1'];

echo '<p id="numba">'.$count++.'.</p>'." <a id='bankr' href='details.php?property={$under}'>".$under."</a><br/>";
echo "<article class='oddOut'> <a title='{$under}' href='details.php?property={$under}'> <img src=".$src."> </a>";

echo "Amount :₦".$_SESSION['price']= $row['price'].' ';
echo "State: ".$_SESSION['state']= $row['state'];
echo "City: ".$_SESSION['city']=$row['city']. "</article>";
//echo $under = $_SESSION['prop'];
}

When an item is clicked, it's session variable ($_SESSION['prop']) should be passed to the detail page where, it's details are output to the browser.


on detail.php
$anger = mysqli_query($grant,"select * from $table where name= '{$_GET['property']}' ") or die(mysqli_error($grant));
while ($caputo = mysqli_fetch_array($anger)) {
echo $caputo['size']."<br/>";
$src=$file_path.$caputo['photo1'];
echo "<a title='{$under}'> <img src=".$src."> </a> <br/>";


}


?>


but what it does is it will select only the last item from the table.
I don't what to use $_GET variable in passing the name of the item, is there any other way i can do this?
#passing #session #variables

Trending Topics