Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "banco";
- # cria conexão
- $link = new mysqli($servername, $username, $password, $dbname);
- # verifica conexão
- if ($link->connect_error) {
- die("Connection failed: " . $link->connect_error);
- }
- # configura utf8 para caracteres especiais
- mysqli_set_charset( $conn, 'utf8');
- $contrato = '';
- $nome = '';
- $tel = '';
- $sql_select = "SELECT contrato, nome, tel FROM teste WHERE contrato LIKE '%$contrato%' AND nome LIKE '%$nome%' AND tel LIKE '%$tel%' ORDER BY contrato;";
- $r = $link->query($sql_select);
- # Primeiro var_dump
- # var_dump($r);
- # exit();
- if(isset($_POST["inserir"])){
- $sql_insert = "INSERT INTO teste (contrato, nome, tel) VALUES ("1000","João","DDD+número"); ";
- $sql_insert .= "INSERT INTO teste (contrato, nome, tel) VALUES ("1001","Maria","DDD+número"); ";
- $sql_insert .= "INSERT INTO teste (contrato, nome, tel) VALUES ("1002","José","DDD+número"); ";
- $link->multi_query($sql_insert);
- # header("location: .");
- $r = $link->query($sql_select);
- # Segundo var_dump
- # var_dump($r);
- # exit();
- }
- $link->close();
- <form action="" method="post">
- <button type="submit" name="inserir" value="inserir">Inserir</button>
- </form>
- object(mysqli_result)#2 (5) { ["current_field"]=> int(0) ["field_count"]=> int(3) ["lengths"]=> NULL ["num_rows"]=> int(0) ["type"]=> int(0) }
- bool(false)
- object(mysqli_result)#2 (5) { ["current_field"]=> int(0) ["field_count"]=> int(3) ["lengths"]=> NULL ["num_rows"]=> int(3) ["type"]=> int(0) }
Add Comment
Please, Sign In to add comment