This should be doable, right? I have a mysql table (‘tb_content’) that has a record for each real estate property listing A web page (‘properties.php’) renders data (property details) that are stored in the table tb_content for one of the listings (‘123 xyz Street’). The query that pulls the page content from the mysql table for the properties.php page is something to the effect of (please excuse the butchering…the code is conceptual) If (isset($_SESSION[‘recordid’])) { $recordid=$_SESSION[‘recordid’]; $sql=SELECT * FROM tb_content WHERE prop_id=$recordid; And so on… } else { //this is the default property $sql=SELECT * FROM tb_content WHERE featuredproperty=’-1’; While…mysql_fetch_array() $recordid = $row[‘prop_id’]; $_SESSION[‘recordid’]= $recordid; And so on. } On properties.php, there is a small section that lists a series of hrefs that represent the rest of the addresses for the other records in tb_content (‘109 Lowe Street’ ‘456 xyz Street’ ‘123 abc Street’ etc…..) Shouldn’t there be a way to have the user click on any one of the hrefs, have the associated prop_id (field name in the table tb_content) would replace the value in $_SESSION[‘recordid’], the page properties.php would re-render, but with the new desired property details? I’ve been failing miserably with everything I’ve tried. I could really use some help.
I wonder why you're working with sessions at all? Passing the variable via $_GET seems way more appropriate in your case.
Here an example. if (isset($_GET['recordid'])) { $sql = "SELECT * FROM tb_content WHERE prop_id = ". intval($_GET['recordid']); } else { $sql = "SELECT * FROM tb_content WHERE featuredproperty = 1"; } $result = mysql_query($sql) OR die( mysql_error() ); while ($row = mysql_fetch_array($result)) { echo "<a href=\"test_loop_hrefs.php?recordid={$row['prop_id']}\">Click Here</a><br />\n"; } PHP: