SirChick Posted September 1, 2007 Share Posted September 1, 2007 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 ?? Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 1, 2007 Share Posted September 1, 2007 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? Quote Link to comment Share on other sites More sharing options...
SirChick Posted September 1, 2007 Author Share Posted September 1, 2007 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. Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted September 1, 2007 Share Posted September 1, 2007 <?php $Price = $_GET["Price"]; ?> will that work? Quote Link to comment Share on other sites More sharing options...
SirChick Posted September 1, 2007 Author Share Posted September 1, 2007 No because say the list loaded: cottage - 50000 apartment - 45000 if i use a GET or POST itll pick the 50000 even if the user had picked the 45000.. It seems to just pick the top of the list regardless of what happens. Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted September 1, 2007 Share Posted September 1, 2007 <?php $Price = $HTTP_POST_VARS["Price"]; ?> Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 1, 2007 Share Posted September 1, 2007 Uhm, you know you have to submit the form for PHP to be able to tell which one they picked, right? Quote Link to comment Share on other sites More sharing options...
SirChick Posted September 2, 2007 Author Share Posted September 2, 2007 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. Quote Link to comment Share on other sites More sharing options...
SirChick Posted September 2, 2007 Author Share Posted September 2, 2007 bump Quote Link to comment Share on other sites More sharing options...
SirChick Posted September 2, 2007 Author Share Posted September 2, 2007 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> Quote Link to comment Share on other sites More sharing options...
SirChick Posted September 2, 2007 Author Share Posted September 2, 2007 bump Quote Link to comment Share on other sites More sharing options...
Hypnos Posted September 2, 2007 Share Posted September 2, 2007 What is the column type of Price? Quote Link to comment Share on other sites More sharing options...
SirChick Posted September 2, 2007 Author Share Posted September 2, 2007 integer is the data type if thats what you mean ? Quote Link to comment 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.