Jump to content

Sessions Help


Lukey

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/52902-sessions-help/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/52902-sessions-help/#findComment-261263
Share on other sites

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]

Link to comment
https://forums.phpfreaks.com/topic/52902-sessions-help/#findComment-261270
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.