SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast Slarti42's Avatar
    Join Date
    May 2001
    Location
    UK
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have read the whole tutorial from Kevin Yank and have found it very helpfull. But my problem is this:
    I have a many-to-many relationship between a distributor table and a county table using a lookup table.

    When I want to insert a new distributor, I want to be able to select multiple values from a list of counties and insert the data into the distributor, and countieslookup table.

    I have got it to display the list of counties as pulled from the database and can select multiple values, but I cant work out how this will send the values because the list has one name and each option has another.

    I read somewhere that it was to do with an array, but I have no idea what I have to do to creat this array and then get the info from the array into the database

    If anyone cane explain this to me in simple terms I'de be very greatfull. My level is still very novice

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well first your select name should be something like name[] with the brackets tacked on:

    PHP Code:
    <select name="countries[]" multiple>
    <
    option value="US">US</option>
    <
    option value="Mexico">Mexico</option>
    <
    option value="UK">UK</option>
    </
    select
    Now on the paghe where you process the form you can simply loop through your array

    PHP Code:
    foreach($countries as $key => $val) {
    print 
    "$key = $val<br>";

    foreach

    That is a basic example and I think you can figure the database part out yourself with this bit of code example.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


Bookmarks

Posting Permissions

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