PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE users (`name` varchar(20), `password` varchar(10)) ; select * from users;
Copy Clear
Copy Format Clear
<? $users = [ ['name' => 'user1','password' => 'pass1'], ['name' => 'user2','password' => 'pass2'], ['name' => 'user3','password' => 'pass3'] ]; $q = mysqli_prepare( $mysqli, "INSERT into `users` (name, password) VALUES (? , ?)" ); $q->bind_param('ss', $name, $password); foreach( $users as $user ) { $name = $user['name']; $password = $user['password']; $q->execute(); } $q_get = mysqli_prepare( $mysqli, "select * from `users`" ); $q_get->execute(); $result = $q_get->get_result(); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { echo "name: " . $row['name'] . " password: " . $row['password']; } } else { echo "Нет записей в таблице."; } $q->close(); $q_get->close();
Show:  
Copy Clear