inserting form select w/ multiple options into mysql

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Smirks
    Senior Member
    • Sep 2002
    • 119
    • 3.0.0 'Gold'

    inserting form select w/ multiple options into mysql

    Howdy,

    I've decided to play around w/ php and mysql tonight and I'm trying to get something working, but I can't figure it out. I'm a beginner at this stuff, so perhaps I'm just doing it all wrong.

    I have a simple database w/ one table that contains a name (varchar(30)) and a list of dates in the format mmddyyyy seperated by spaces. Example:
    Code:
     
    +--------+----------------------------------------------------------------+
    | name   | dates							  |
    +--------+----------------------------------------------------------------+
    | Joe	 | 04282003 04302003 05032003 07022003 07052003 07082003 07092003 |
    +--------+----------------------------------------------------------------+
    Now, I'm trying to create a from to input rows into that table in that format. I'm specifically having a hard time returning the dates to be inserted properly.

    I have a select form like this:
    Code:
    <select name=\"dates[]\" size=10 multiple>
      <option value=04282003>04/28/2003<br>
      <option value=04302003>04/30/2003<br>
      <option value=05032003>05/03/2003<br>
      <option value=07022003>07/02/2003<br>
      <option value=07052003>07/05/2003<br>
      <option value=07082003>07/08/2003<br>
      <option value=07092003>07/09/2003<br>
    </select>
    Now when the form submits it puts all the results into an array, afaik. How can I extract the values from this array so they are suitable for inserting into the database?

    I've been workin on this for a few hours, and I think I'm close, but I just can't get it!

    Thanks!
    PJnet BBS .:. RU Forums
  • mr e
    New Member
    • Aug 2002
    • 18

    #2
    i think you'll have to assign each option a name and then use the name as the variable to put into the db

    Comment

    • Icheb
      Senior Member
      • Nov 2002
      • 1291

      #3
      Why not use MySQL's possibilities for relational datastructure?

      Have two tables:
      Table 1 with the columns userid and username.
      Table 2 with the columns userid and dates.

      Read up on JOINs in your favorite MySQL book or on www.mysql.com .

      Comment

      • Smirks
        Senior Member
        • Sep 2002
        • 119
        • 3.0.0 'Gold'

        #4
        Originally posted by Icheb
        Why not use MySQL's possibilities for relational datastructure?

        Have two tables:
        Table 1 with the columns userid and username.
        Table 2 with the columns userid and dates.

        Read up on JOINs in your favorite MySQL book or on http://www.mysql.com .
        'Cause I'm not up to that point yet.

        I want to make it work very easily and simply like this, then I'll work on ways to make it better.

        Other than that, implode() was the function I was looking for.

        PHP Code:
        $array implode(" ","$dates"); 
        PJnet BBS .:. RU Forums

        Comment

        widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
        Working...