Buonasera a tutti,
ho un semplice select multiplo in un form:
Codice HTML:
codice:
<select multiple="multiple" id="nome"> ecc. ecc..
con un js che mi prende i dati
Codice:
codice:
function addRecord() { var term_nome = $('#nome').val(); //Storing the value of textbox into a variable if(term_nome == '') //Checking for NULL { $('#propspectDiv').html('Inserire i dati obbligatori'); //Prints the progress text into our Progress DIV return; } else{ $('#propspectDiv').removeClass('error'); //Removing the error class from the progress DIV $('#propspectDiv').html('Attendere prego...
[img]ajax.gif[/img]'); //Prints the progress text into our Progress DIV $.ajax({ url : 'data.php', //Declaration of file, in which we will send the data data:{ "nome" : term_nome, //we are passing the nome value in URL }, success : function(data){ window.setTimeout(function(){ $('#propspectDiv').html('Grazie, la missione è stata registrata'); //Prints the progress text into our Progress DIV $('#data').css("display","block"); //Changes the style of table from display:none to display:block $('#data').html(data); //Prints the data into the table }, 1500); } }); } }
e un php che mi salva su db mysql
Codice PHP:
Codice PHP:
<?php $nome = $_REQUEST['nome']; $con = mysql_connect("localhost","root",""); mysql_select_db("missioni", $con); $sql = 'INSERT INTO `data` (`ID`, `nome`) VALUES (NULL,"'.$nome.'")'; if (!mysql_query($sql,$con)) { die('Errore: ' . mysql_error()); } else{ $sqlnew = 'SELECT * from missioni ORDER BY ID desc LIMIT 1;'; $res = mysql_query($sqlnew); while($row = mysql_fetch_array($res)) { echo ' <p class="lead text-success">'.$row['nome'].'</p> '; } } mysql_close($con); ?>
Il problema è che dal select multiplo il valore che mi salva è "array".
come bisogna fare per impostare il salvataggio dei valori impostati, casomai separati da virgola ?
grazie