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
Share      Blog   Popular

PHPize.online is a free online environment for quickly running, experimenting with and sharing PHP (including Carbon extension for DateTime) and SQL code. You can run your SQL code with PHP code that can use the same DB. For database manipulations you can use pre-defined instances of PDO ($pdo), mysqli ($mysqli) & Laravel query builder ($db)

Copy Format Clear
CREATE TABLE customer ( id int, name varchar(64), phonenumber varchar(64), email varchar(64), country varchar(64) ); INSERT INTO customer (id, name) VALUES (1, 'First Customer1'), (2, 'Second Customer 2'), (3, 'Customer3'), (5, 'Customer5');
Copy Clear
Copy Format Clear
<?php // include "conn.php"; $conn = &$mysqli; $_GET["submit"] = 'submit'; $_GET["search"] = 'Second'; $limit = 5; $fetch = mysqli_query($conn, "select * from customer"); $total_rows = mysqli_num_rows($fetch); $total_pages = ceil($total_rows / $limit); if (!isset($_GET["page"])) { $page_number = 1; } else { $page_number = (int)$_GET["page"]; } $initial_page = ($page_number - 1) * $limit; $fetch = "SELECT * FROM customer LIMIT " . $initial_page . "," . $limit; if (isset($_GET["submit"])) { $search = $_GET["search"]; if (empty($search)) { echo "empty"; } else { $fetch = "SELECT * FROM customer where name LIKE '$search%' OR phonenumber LIKE '$search%' OR email LIKE '$search%'OR country LIKE '$search%' LIMIT " . $initial_page . "," . $limit; } } $result = mysqli_query($conn, $fetch); while ($row = $result -> fetch_assoc()) { print_r($row); }
Show:  
Copy Clear