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 booking (id int, name varchar(20)); INSERT INTO booking (id, name) VALUES (1, 'Booking 1'), (2, 'Booking 2'); CREATE TABLE booking_line (id int, booking_id int,is_repeat int, description varchar(20)); INSERT INTO booking_line (id, booking_id,is_repeat, description) VALUES (3, 1,1, 'Line 1'),(3, 1,0, 'Line 1'), (2, 1,1, 'Line 2'), (4, 2,1, 'Line 3');
Copy Clear
Copy Format Clear
<?php $repeat_query= "SELECT a.id, a.booking_id,a.description, b.id AS book_id,b.name FROM booking_line a JOIN booking b ON a.booking_id = b.id WHERE a.is_repeat = '1' ORDER BY b.name"; $i=0; if ($r_result = mysqli_query($mysqli, $repeat_query)) { // Return the number of rows in result set $rowcount = mysqli_num_rows( $r_result ); // Display result //echo $rowcount."<br>"; $repeat = array(); $repeat_user = array(); while($repeat_row = mysqli_fetch_assoc($r_result)) { $repeat[] = $repeat_row; } } print_r($repeat);
Show:  
Copy Clear