Storing variables (numbers) inside a text area and into db

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Lazairus
    New Member
    • Mar 2008
    • 3

    Storing variables (numbers) inside a text area and into db

    i have code in a text area , i want the user to enter a number (units of alcohol )
    and post the number to a mysql database , i want to store the number only and inside the drink () units . ie i want to put the code that reads from the brackets and insterts into a php script which stores the value in a database

    How is this done????

    please help &much apprieciated ,
    laz
    Code below
    [php]
    <td align="left" valign="middle" ><table width="365" height="61" border="1">
    <tr>
    <td width="182"><te xtarea name="drink_uni t" id="drink_unit" >I drink () units of alcohol week</textarea></td>
    <td width="167">for unit information please click here</td>
    </tr>
    </table></td>
    </tr>[/php]
    Last edited by ronverdonk; Mar 19 '08, 10:37 PM. Reason: code tags inserted
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Please enclose your posted code in [code] tags (See How to Ask a Question).

    This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

    Please use [code] tags in future.

    MODERATOR

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      You enclose the textarea input field in a <form>. You also include a submit button in that form. When the uset submits the form, it is submitted to the script you define in the form statement.
      In that 'catching' script you retrieve the value from the $_POST (or $_GET) array, make a connection to the db and insert the value in an MySQL INSERT statement.

      That's it.

      The following is a link to a tutorial on making a html form and inserting the data into the database HERE
      Do that tutorial, write the code yourself and come back when you have problems.

      Ronald

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Originally posted by ronverdonk
        You enclose the textarea input field in a <form>. You also include a submit button in that form. When the uset submits the form, it is submitted to the script you define in the form statement.
        In that 'catching' script you retrieve the value from the $_POST (or $_GET) array, make a connection to the db and insert the value in an MySQL INSERT statement.

        That's it.

        The following is a link to a tutorial on making a html form and inserting the data into the database HERE
        Do that tutorial, write the code yourself and come back when you have problems.

        Ronald
        I think he's asking for a way to retrieve what the user inputs BETWEEN the brackets.
        I.e, i drink (more than mary does) in a week ;
        db-> "more than mary does" ;

        Can't lend a hand though, im off to bed!

        Regards.

        Comment

        • ronverdonk
          Recognized Expert Specialist
          • Jul 2006
          • 4259

          #5
          Thanks marcusn00b!

          My previous post still stands, only you have to make the statement like this
          Code:
          <td width="182">I drink <input type="text" name="drink_unit" style="width:20px;" /> units of alcohol per week</td>
          .
          You still have to submit it to a receiving script and catch the content of $_POST['drink_unit'] (or from the $_GET['drink_unit'] depending on the method used to submit the form.)

          Ronald

          Comment

          Working...