Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Oct 2011
    Thanked 0 Times in 0 Posts

    SELECT / UPDATE table using $variable

    Hi Everyone,

    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

    PHP Code:

    "SELECT propertyid FROM propertylisting WHERE username = '$username'";
    $update"UPDATE INTO propertylisting WHERE propertyid='$id' ADD (bathrooms varchar(2))"// This is what I mean
    I hope this makes sense...
    Last edited by rexhvn; 06-25-2013 at 12:14 PM.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Thanked 4,323 Times in 4,289 Posts
    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' ";
    But *PLEASE* don't make the field BATHROOMS be VARCHAR(2)!!!

    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.


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts