Ok, before you do anything else, have a read of
this page.
It's important that you have a good read of it, even if you dont really 'get' it, because all of your problems here seem to relate in some way to arrays and the way you are trying to use them.
As far as the SQL goes, I don't know your database, so I really am flying blind with it. However, assuming you are just attempting to reference an existing database field and have just forgotten to query it, you would change this ...
Code: Select all
$soldhousesquery = "SELECT Price, HouseType FROM soldhouses ORDER BY Price ASC";
to this ...
Code: Select all
$soldhousesquery = "SELECT SoldHouseID, Price, HouseType FROM soldhouses ORDER BY Price ASC";
When this command is executed
Code: Select all
$soldhousesrow = mysql_fetch_array($soldhousesresult)
it will return an array of the fields (columns) relating to a single record (row). When you specify columns to return (between SELECT and FROM) they will be the ONLY values returned.
Now, with the POST array, the way you are trying to access it is wrong on a few different levels. Firstly, to my knowledge, you cannot access an array with the syntax
Someone may correct me on that, but I don't think so. Direct access to an array element should always be in the form of
As for using a variable as the key for the array, this is possible - with the format
Code: Select all
$key = "something";
echo $_POST[$key]
or even
However, what you are trying to do here
is access an array using the wrong format, using a key which by your reckoning would equate to a value, not a key. Worse that that though, the value you are aiming at accessing is not set, because it is not passed to the second page via the form as you suspect.
When you submit a form, the $_POST array will store a series of values in the format "form control name"=>"form control value". Accessed with ...
The form you specify has two controls, "houselist" and "buy", as shown when you var_dump the post value.
array(2) { ["houselist"]=> string(0) "" ["Buy"]=> string(9) "Buy House" }
So, accessing $_POST, you only have access to "houselist" and "Buy". You can add hidden fields to your form to carry the extra data across, or you can fix the SQL as shown above, and use the SoldHouseID stored as a value in the form as "houselist" and run a second query on the second page to get access to the extended data.
I've tried to lay this all out as simply as I can without actually rewriting your code for you. I hope it helps.