mysqli - some checkbox with one buttom for some row to insert in different table php -


i have problem. want insert row (each select checkbox) database table. have pages:

ricercatitoli.php

<div id="ricerca" class="content">     <form action="ricercatitoli.php" method="post">         <p>inserire il titolo</p><input type="text" name="titol" class="test">         <p>inserire il numero</p><input type="text" name="numer" class="test">         <br><br>         <center><input type="submit" value="ricerca" class="btn"></center>         </form>     </div> 

ricercatitoli.php

<?php $servername = "localhost"; $username = "root"; $password = "ephp"; $db="magazzino";  $titolo = isset($_post["titol"]); $numero = isset($_post["numer"]);  // create connection $conn = mysqli_connect($servername, $username, $password, $db);  // check connection if (!$conn) {     die("connessione fallita: " . mysqli_connect_error()); }  var $tipo="";  // query db if ($numero ==null) {$tipo=1; }elseif (($titolo !==null) , ($numero !==null)){     $tipo=2;}  switch ($tipo) { case 1:     $sql = "select * `articoli` `titolo` '%$titolo%' order `data_uscita` desc limit 30";     break; case 2:     $sql = "select * `articoli` `titolo` '%$titolo%' , `numero_volume`= '$numero' order `data_uscita` desc limit 30";     break;     default:     echo "compila il primo o entrambi campi"; }  // connection plus query $result = mysqli_query($conn, $sql) or die(mysqli_error($conn));  $number = mysqli_num_rows($result);  if ($number == 0) {     echo "nessun risultato trovato. riprovare"; } else {     echo "<table class='tabella'>";     echo "<tr><th>editore</th><th>collana</th><th>n&#176 collana</th><th>serie</th><th>titolo</th><th>n&#176</th><th>prezzo</th><th>carrello</th></tr><br>";     while ($row = mysqli_fetch_array($result))         {             echo "<tr><td>" . $row['editore'] . "</td><td>". $row['collana'] . "</td><td>". $row['numero_collana'] . "</td><td>" . $row['serie'] . "</td><td>". $row['titolo'] . "</td><td>". $row['numero_volume'] . "</td><td>". $row['prezzo'] . "</td><td><input type='checkbox' value='aggiungi al carrello' class='btn'></td></tr>";             echo "<br>";         }        echo "</table>"; }  include('aggiungialcarrello.php'); mysqli_close($conn); ?> 

aggiungialcarrello.php

<?php $servername = "localhost"; $username = "root"; $password = "ephp"; $db="magazzino";  // create connection $conn = mysqli_connect($servername, $username, $password, $db);  // check connection if (!$conn) {     die("connessione fallita: " . mysqli_connect_error()); }  //query db $sql = "insert `carrello` (`id_articolo`, `editore`, `collana`, `numero_collana`, `serie`, `titolo`, `numero_volume`, `prezzo`, `quantita`, `data_uscita`, `categoria`) values (null,".$row['editore'].", ".$row['collana'].", ".$row['numero_collana'].", ".$row['serie'].", ".$row['titolo'].", ".$row['numero_volume'].", ".$row['prezzo'].",null ,".$row['data_uscita'].", ".$row['categoria'].")";  // connection plus query mysqli_query($conn, $sql) or die(mysqli_error($conn));  include('smista.php'); mysqli_close($conn); ?> 

when found 1 or more record, if checked it, can insert record (row[]) table (carello) but, after days, can't found answer. work in mysqli. need solution school project.


noe ricercatitoli.php is:

<?php $servername = "localhost"; $username = "root"; $password = "ephp"; $db="magazzino";  isset($titolo = $_post["titol"]); isset($numero = $_post["numer"]);  // create connection $conn = mysqli_connect($servername, $username, $password, $db);  // check connection if (!$conn) {     die("connessione fallita: " . mysqli_connect_error()); }  var $tipo="";  // query db if ($numero ==null) $tipo=1; }elseif (($titolo !==null) , ($numero !==null)){     $tipo=2;}  switch ($tipo) { case 1:     $sql = "select * `articoli` `titolo` '%$titolo%' order `data_uscita` desc limit 30";     break; case 2:     $sql = "select * `articoli` `titolo` '%$titolo%' , `numero_volume`= '$numero' order `data_uscita` desc limit 30";     break;     default:     echo "compila il primo o entrambi campi"; 

}

// connection plus query $result = mysqli_query($conn, $sql) or die(mysqli_error($conn));  $number = mysqli_num_rows($result);  if ($number == 0) {     echo "nessun risultato trovato. riprovare"; } else {     echo "<table class='tabella'>";     echo "<tr><th>editore</th><th>collana</th><th>n&#176 collana</th><th>serie</th><th>titolo</th><th>n&#176</th><th>prezzo</th><th>carrello</th></tr><br>";     while ($row = mysqli_fetch_array($result))         {             echo "<tr><td>" . $row['editore'] . "</td><td>". $row['collana'] . "</td><td>". $row['numero_collana'] . "</td><td>" . $row['serie'] . "</td><td>". $row['titolo'] . "</td><td>". $row['numero_volume'] . "</td><td>". $row['prezzo'] . "</td><td><input type='checkbox' value='aggiungi al carrello' class='btn'></td></tr>";             echo "<br>";         }        echo "</table>"; }  //include('aggiungialcarrello.php'); mysqli_close($conn); 

?>


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -