Jump to content

Won't save selection by user


SirChick

Recommended Posts

I have a selection designed in a html which loads up the rows from a table but displays only house type and price. Which works. But say the user picks the first choice:

 

Cottage - £50000

 

Oddly $housetype = cottage

but

$Price = 

 

 

This is the selection creation:

echo '<select name="houselist" size=10>">';

while($soldhousesrow = mysql_fetch_array($soldhousesresult)) {
        echo "<option value=\"{$soldhousesrow['Price']}|{$soldhousesrow['HouseType']}\">£ {$soldhousesrow['Price']} - {$soldhousesrow['HouseType']}</option>";
}

echo '</select>';

 

 

The creation:

 

$_SESSION['Price'] = $soldhousesrow['Price'];
$_SESSION['HouseType'] = $soldhousesrow['HouseType'];

 

 

Then i have this on a different page:

 

$Price = $_SESSION["Price"];
$HouseType = $_SESSION["HouseType"];

Echo $Price;
Echo $HouseType;

 

 

Result :

 

Cottage

(then blank)

 

 

 

Any idea why this is happening only for house type ??

Link to comment
Share on other sites

Well for one, it looks like you have price and house type backwards, as everywhere you have price it prints cottage.

Secondly, you're doing this:

$_SESSION['HouseType'] = $soldhousesrow['HouseType'];

 

Out of the while loop. Where is the value of $soldhousesrow['HouseType'] coming from at that point? It looks like it is not set there.

Where do you set it?

Link to comment
Share on other sites

wait the echo's of

 

cottage

(and blank)

 

i didnt mean it in that order.. basically $price is blank but houestype is not.

 

 

But what do you mean by "set".

As you see on this line from the above script

 

echo "<option value=          etc

 

 

What ever the user chooses is what will be set into that session... am i right in thinking that? It works for housetype but not price though thats what i dont get.

Link to comment
Share on other sites

Jesi - Yeah theres a submit button.. or do you mean by using _POST ?

 

I originally tried the _POST but that didn't work. Can't use GET because the form is POST and

$Price =  $HTTP_POST_VARS["Price"];
didn't work either.

 

What confuses me is how House Type does work but not price...even when they are processed in the exact same way.

Link to comment
Share on other sites

This is the recent script i tried for it to start working but im still getting the same result:

At the very top of this script i have posted below is :

 

require "energybarinclude.php";

 

this contains the session_start(); just so you know.

 

<form name="Form1" method="POST" action="housepurchaseprocess.php" enctype="multipart/form-data" id="Form1" onsubmit="return ValidateForm1(this)">

<?php

$soldhousesquery = "SELECT Price, HouseType FROM soldhouses ORDER BY Price ASC";
$soldhousesresult = @mysql_query($soldhousesquery) or die(mysql_error());


echo '<select name="houselist" size=10>">';

while($soldhousesrow = mysql_fetch_array($soldhousesresult)) {
        echo "<option value=\"{$soldhousesrow['Price']}|{$soldhousesrow['HouseType']}\">£ {$soldhousesrow['Price']} - {$soldhousesrow['HouseType']}</option>";
}

echo '</select>';

//these 2 sessions when echo'd only house type displays but not price
$Price = $_POST['Price'];
$HouseType = $_POST['HouseType'];
$_SESSION['Price'] = $Price;
$_SESSION['HouseType'] = $HouseType;

?>
</div>
<input type="submit" id="Button2" name="Buy" value="Buy House" style="position:absolute;left:350px;top:600px;width:184px;height:24px;z-index:20">
</form> 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.