Lukey Posted May 25, 2007 Share Posted May 25, 2007 I have created a database with a table called houses with various house information as fields. My search page is working fine and loads up each result in a separate table using a loop: while($newarray = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $rname = $newarray["hname"]; $rcountry = $newarray["hcountry"]; $rbeds = $newarray["beds"]; $rprice = $newarray["hprice"]; ?> <table cellspacing="0" cellpadding="4" border="1" width="80%" bgColor="#ccff99" borderColor="#ffcccc"> <tr><form action="http://localhost/housedetail.php" method="post"> <!-- Row 1 Column 1 --> <td> <img src="C:\Documents and Settings\Lukey\Desktop\MAIN PROJECT\<?php echo($rname);?>.jpg"> </td> <!-- Row 1 Column 2 --> <td><div align="left"> <?php echo"<li>$rname</li><br/>"; echo"<li>$rcountry</li><br/>"; echo"<li>$rbeds Bedrooms</li><br/>"; echo"<li><i>£ $rprice</i></li><br/>"; session_start(); $_SESSION['housename'] = $rname; ?></div> </td> <!-- Row 1 Column 3 --> <td> <center><h5>Please Click the Button for futher details</h5><br/> <input type="submit" value=" House Details "/></center> </td> </tr> </form> </table> <?php echo"<br/>"; } However i have a button in each result table which links to a php script that loads up a page with further details of the house. I decided to use SESSIONS to pass the housename to the next script so i can retrive the data and display it BUT i can only start one session at a time and because it loops i get errors on my page: Notice: A session had already been started - ignoring session_start() in C:\Program Files\Apache Group\Apache2\htdocs\housesearch.php on line 210 Any help would be most appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/52902-sessions-help/ Share on other sites More sharing options...
corbin Posted May 25, 2007 Share Posted May 25, 2007 Ummm yeah why would you need more than one session going at a time? Since it's an array you can just use $_SESSION['somevar'] = "something"; $_SESSION['someothervar'] = "Somethineelse"; etcetera. You should be able to safely delete the session_start on line 210 of housesearch.php, but I didn't read your code... so.... lol Quote Link to comment https://forums.phpfreaks.com/topic/52902-sessions-help/#findComment-261263 Share on other sites More sharing options...
mmarif4u Posted May 25, 2007 Share Posted May 25, 2007 And try to put ur session at very top of the page. And use one session at a time in one page, mean script. <?php session_start(); Rest of ur code. ?> Quote Link to comment https://forums.phpfreaks.com/topic/52902-sessions-help/#findComment-261265 Share on other sites More sharing options...
Lukey Posted May 25, 2007 Author Share Posted May 25, 2007 Aha thanks that was a stupid thing to miss however it has given me a different problem in that the only variable it is passing to the next script is the last record of the results and not the correct one clicked As you can see in the attached screenshot i am aiming to get the button to pass the correct housename across. [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/52902-sessions-help/#findComment-261270 Share on other sites More sharing options...
Lukey Posted May 25, 2007 Author Share Posted May 25, 2007 BUMP Anyone have an idea how i can split the array up into so that i can pass the correct housename variable to the next script? Quote Link to comment https://forums.phpfreaks.com/topic/52902-sessions-help/#findComment-261297 Share on other sites More sharing options...
siwelis Posted May 25, 2007 Share Posted May 25, 2007 This should work... print $array[0]; Depending on how many array's you have, the variable is either 0 - ** where star is being the last one. if you want to use only 0, 3 and 7, then it would be echo $array[0] $array[3] $array[7]; Quote Link to comment https://forums.phpfreaks.com/topic/52902-sessions-help/#findComment-261311 Share on other sites More sharing options...
Lukey Posted May 25, 2007 Author Share Posted May 25, 2007 Its ok mate i bodged my way around it by adding a html hidden type input and putting each housename into that as it goes through the loop. Each hidden box with the variable value has a corresponding button and it works! Quote Link to comment https://forums.phpfreaks.com/topic/52902-sessions-help/#findComment-261313 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.