Question

Hi I am pretty new to php, trying to do this account page, the php use $session_username to draw out a row(listingname) from the database, the individual result are turned into links, they all link to another php. And what i am trying to do is, $SESSION the specific Listingname as i clicked on it.

For Example, Within the row of Listing name there are John, Ben, Tom, They are within the Array, they are all individual links, when clicked it goes to list.php, and what i want to do is. When John is clicked, $SESSION_['listingname'] will be John, and if Ben is clicked, the $SESSION_['listingname'] will be Ben etc. So then i can use that name to pull more info from the database related to that name inside List.php.

THanks for your time!

php

<?php

ini_set('display_errors', 1); error_reporting(E_ALL);

session_start();
include 'connect.php';

echo "Welcome  ".$_SESSION['username'];
echo "</br>";
echo $_SESSION['password'];
echo "</br>";
echo "</br>";



{





?>

<FORM METHOD="LINK" ACTION="Submitlisting5.php">
<INPUT TYPE="submit" VALUE="Go to submit">
</br>
</br>

</FORM>
Existing List
</br>
<?php
ini_set('display_errors', 1); error_reporting(E_ALL);


include 'connect.php';
$username=$_SESSION['username'];


$result=mysqli_query($con,"SELECT * FROM Listing WHERE username = '$username'")or die( mysqli_error($con));

while ($row = mysqli_fetch_assoc($result))
        {

          echo '<a href="SpecificListing.php">'.$row['Listingname'].'</br>';
        }
        $_SESSION['Listingname']=$row['Listingname'];
}



?>
Was it helpful?

Solution

You should pass the link to the next page.

For instance :

echo '<a href="SpecificListing.php?listingName='.urlencode($row['Listingname']).'">'.$row['Listingname'].'</br>';

And on SpecificListing.php you can set

$_SESSION['Listingname'] = $_GET['listingName'];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top