Is it possible to insert data into different database based on user input?

Discussion in 'PHP' started by php_noobie, May 27, 2008.

  1. #1
    Hi there I am a php noob needing help. I am currently doing coding for my project, which is a hotel website. One of the hotel facilities is a spa and we have multiple spa rooms with different timeslots, as such it wasn't possible to store all the information into 1 big table because of repeating values(multiple timeslots for the same room number). Thus we have created separate tables for each spa room

    In our spa room booking interface, the user have got to select the types of room that they want and based on this, the data they entered into the form will be appended into the corresponding table. Does anyone how to code the PHP script to achieve this logic?
    To give clearer picture--

    e.g. If user select Room type A the other data he entered(e.g. timeslot and name) will be appended into the table designed to hold information of user who select room type B. If room type B selected, another table will store the user information instead

    So how to achieve this? use if-else statement? If possible maybe can show a sample code here. Thanks!
     
    php_noobie, May 27, 2008 IP
  2. Sevby

    Sevby Guest

    Messages:
    36
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can put a variable into another variable. This is one of the first things you should've learnt in PHP.

    $foo = "Joe";
    $bar = "My name is $foo.";
    echo $bar;
    Code (markup):
    This will echo: My name is Joe.
     
    Sevby, May 28, 2008 IP
  3. php_noobie

    php_noobie Peon

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    So your point being?

    How is it useful to solve my problem?
     
    php_noobie, May 28, 2008 IP
  4. Sevby

    Sevby Guest

    Messages:
    36
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I thought it would've been obvious. Assuming the user input is coming from $_GET or $_POST, you could use those variables in your query.

    Otherwise, where is the user input coming from?
     
    Sevby, May 28, 2008 IP