I would look into doing something like this.

The HTML code that Wouter will work just fine.  My ideas are for the process
page.

When you insert data into a table, it has to re-index the table if you make
your statement insert all the data at one time it will only re-index the
table one time.

It goes a little something like this.

<?php
if(isset($_POST['somename'])) {
  print_r($_POST['somename']);

  echo "<BR>";

  foreach($_POST['somename'] AS $k => $v) {
    $values[] = " (NOW(), '{$v}') ";
  }
  if(count($values)) {
    $insert_sql = "INSERT INTO table_name (date, myValue) VALUES " . join("
VALUES ", $values);
    echo $insert_sql;
  } else {
    echo "Nothing to insert";
  }
}
?>
<FORM METHOD=POST>
    <SELECT name='somename[]' size=10 multiple id='somename[]'>
        <OPTION value='one'>First Thingie</OPTION>
        <OPTION value='two'>Second Thingie</OPTION>
        <OPTION value='three'>Third Thingie</OPTION>
        <OPTION value='four'>Fourth Thingie</OPTION>
        <OPTION value='five'>Fifth Thingie</OPTION>
    </SELECT>
    <INPUT TYPE='SUBMIT'>
</FORM>

Give the above script a shot and see if it does what you want it to do.

Jim Lucas

----- Original Message -----
From: "Frank Keessen" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, June 03, 2003 11:55 AM
Subject: [PHP] Multi Selection


> Hi Guys,
>
> I'm trying to do the following:
>
> I've got a multiple selection box build out of a query of table
>
> <td><select name="VALUE[]" size="10" multiple id="VALUE[]">
>   <?
> $query2 = "SELECT SomethingID, Somewhere FROM Someplace WHERE publiceer =
'yes' ORDER BY somewhere";
> $result2 = mysql_query($query2) or die ("Error in query: $query2. " .
mysql_error());
>
> if (mysql_num_rows($result2) > 0)
>  {
>   while($row2 = mysql_fetch_object($result2))
>   {
> ?>
>
>     <OPTION VALUE="<? echo $row2->SomethingID ?>"><? echo $row2->Somewhere
; ?>
> <?
>  }
> }
> ?>
> </option>
> </select>
>
> The outcome is stored in the VALUE[]..
>
> Now i want to have an INSERT query that insert each value seperatly..
>
> So if there are 3 selections it must be repeat the INSERT query three
times...
>
>
> Thanks for the help!
>
>
> Frank
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to