Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
06-25-2013, 11:53 AM #1
- Join Date
- Oct 2011
- Thanked 0 Times in 0 Posts
SELECT / UPDATE table using $variable
I hoping to get some assistance. I'm creating an upload property form consisting of four different pages, each page requiring different information.
Page1 - requiring information about the property. I have created my table based on what is required from this this page only.
This is what it looks like with information inputted from page 1
All this works great. Once I get to page 2 this then requires further information (no. Bathrooms, bedrooms garage etc). What I want to do (if possible) is add Bathrooms/Bedrooms/Garage to this column based on information already submitted. So by the end, the image above with contain alot more information
$id = "SELECT propertyid FROM propertylisting WHERE username = '$username'";
$update= "UPDATE INTO propertylisting WHERE propertyid='$id' ADD (bathrooms varchar(2))"; // This is what I mean
Last edited by rexhvn; 06-25-2013 at 12:14 PM.
06-25-2013, 07:32 PM #2
You must *FIRST* add those fields to your table.
Use your MySQL tools to do that. Not coding.
Then it's easy:
$sql = "UPDATE propertylisting SET bathrooms = $bathrooms WHERE username = '$username' ";
It's a *NUMBER* so TREAT IT AS A NUMBER!!!!
Since many real estate listings will show "2.5 baths", you need to make it either a FLOAT value or perhaps DECIMAL(6,2) or similar.An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.