Ho un menu dinamico dal quale posso selezionare più username contemporaneamente.
Ho necessità di salvare nel database mysql una riga per ogni username.
In questa riga i campi 'presente' ed 'evento' hanno il medesimo valore per tutti gli usernames selezionati.
Come si puo' fare?
Così com'è salva una sola scelta tra tutte quelle selezionate e la funzione implode applicata sul campo username non funziona.
Codice PHP:
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING']))
{ $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); }
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1"))
{ $insertSQL = sprintf("INSERT INTO partecipanti (evento, username, presente) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['evento'], "text"),
GetSQLValueString($_POST['username'], "text"),
GetSQLValueString($_POST['presente'], "int"));
mysql_select_db($database_server, $server);
$Result1 = mysql_query($insertSQL, $server) or die(mysql_error());
$insertGoTo = "modificapresenti.php";
if (isset($_SERVER['QUERY_STRING']))
{ $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING']; }
header(sprintf("Location: %s", $insertGoTo)); }
<select name="username" size="12" multiple="multiple">
<?php do { ?>
<option value="<?php echo $row_elencosenzarisposta['hash']?>">
<?php echo $row_elencosenzarisposta['fname']." ".$row_elencosenzarisposta['lname']?></option>
<?php } while ($row_elencosenzarisposta = mysql_fetch_assoc($elencosenzarisposta));
$rows = mysql_num_rows($elencosenzarisposta);
if($rows > 0) { mysql_data_seek($elencosenzarisposta, 0);
$row_elencosenzarisposta = mysql_fetch_assoc($elencosenzarisposta); } ?>
</select>