PHP / MySQL Question - Select From Database

Discussion in 'PHP' started by LindseyInteractive, Dec 26, 2011.

  1. #1
    Okay here is my question.

    Let's say I have a value that was given to me by a form submission, and I want to take that value, and search our database for that value, and pull all the information in that row based on the value that was sent from the form.

    So, lets say that the information provided from the form submissions was "Budget" I know I would do this:

    $Submission_Result = $_Post['Name_Of_Value'];

    So, now the value from the Form is stored in $Submission_Result


    So, now I want to search a database called "Services" for the "Budget" or $Submission_Result Row, and then take the rest of the values from that row (which is price, term of service) and put them in an array.

    This is where I get confused, with the Select commands in the SQL. Which command to use, to select all the values in that row, based on the value put in $Submission_Result.
     
    LindseyInteractive, Dec 26, 2011 IP
  2. stats

    stats Well-Known Member

    Messages:
    586
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    110
    #2
    $q = mysql_query("SELECT * FROM `your_table` WHERE `your_row` = '$Submission_Result'"); // run the query, don't mess up with the quotes <table> and <row> names go inside `tablename` and values go inside 'value'

    while ($line = mysql_fetch_assoc($q)) {
    $result[] = $line; // put each array containing a result set into the final (multidimensional) array of your result
    }

    print_r($result);

    just run this, you'll be fine from there
     
    stats, Dec 26, 2011 IP