PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE customer ( id int, name varchar(64) ); INSERT INTO customer VALUES (1, 'Customer1'), (2, 'Customer2'), (3, 'Customer3'), (5, 'Customer5');
Copy Clear
Copy Format Clear
<?php // include "conn.php"; $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 = mysql_fetch_assoc($result)) { print_r($row); }
Show:  
Copy Clear