PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE products (id int auto_increment primary key, name varchar(255)); CREATE TABLE feedbacks (id int auto_increment primary key, product_id int, feedback text, foreign key (product_id) references products(id)); INSERT INTO products (name) VALUES ('Best Product'), ('Good Product'); INSERT INTO feedbacks (product_id, feedback) VALUES (1, 'Awesome'), (2, 'May be better');
Copy Clear
Copy Format Clear
<?php printf("Current PHP version: %s \n", phpversion()); $query = "SELECT VERSION() as version;"; $stmt = $pdo->prepare($query); $stmt->execute(); $row = $stmt->fetch(PDO::FETCH_ASSOC); printf('DB version: %s', $row['version']); $results = $mysqli->query(" SELECT * FROM feedbacks JOIN products ON products.id = product_id ORDER BY id desc limit 8"); while($row = $results->fetch_assoc()) { echo '<p>'.$row["feedback"].'</p><p>'.$row["name"].'</p> '; }
Show:  
Copy Clear