Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Login    Share code      Blog   FAQ

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

Copy Format Clear
-- Hint: use Ctrl+Enter for SQL autocomplete CREATE TABLE `register` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `gender` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; INSERT INTO `register` (`id`, `user`, `email`, `gender`) VALUES (1, 'doe', 'doe@example.com', 'male'), (2, 'jane', 'jane@example.com', 'female');

Stuck with a problem? Got Error? Ask AI support!

Copy Clear
Copy Format Clear
<?php function data_user() { global $mysqli; $query = "SELECT * FROM register"; $select = $mysqli->query($query); $rows = []; if (mysqli_num_rows($select)) { while ($row = mysqli_fetch_assoc($select)) { $rows[] = $row; } return $rows; } else { die('data not found'); } } $users = data_user(); ?> <tr> <td>user</td> <td>email</td> <td>gender</td> <td>id</td> </tr> <?php foreach($users as $user) : ?> <tr> <td><?php echo $user['user']; ?></td> <td><?php echo $user['email']; ?></td> <td><?php echo $user['gender']; ?></td> <td><?php echo $user['id']; ?></td> </tr> <? endforeach ?>
Copy Clear