Semplice problema post da multiple select
-
Buonasera a tutti,
ho un semplice select multiplo in un form:<select multiple="multiple" id="nome">con un js che mi prende i dati
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...<br><img src="ajax.gif" />'); //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
<?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 dato che mi salva è "array".
come bisogna fare per impostare il salvataggio dei valori impostati, casomai separati da virgola ?
grazieMP
Ciao! Sembra che tu sia interessato a questa conversazione, ma non hai ancora un account.
Stanco di dover scorrere gli stessi post a ogni visita? Quando registri un account, tornerai sempre esattamente dove eri rimasto e potrai scegliere di essere avvisato delle nuove risposte (tramite email o notifica push). Potrai anche salvare segnalibri e votare i post per mostrare il tuo apprezzamento agli altri membri della comunità.
Con il tuo contributo, questo post potrebbe essere ancora migliore 💗
Registrati Accedi