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
CREATE TABLE classics ( author VARCHAR(128), title VARCHAR(128), category VARCHAR(16), year SMALLINT, isbn CHAR(13), INDEX(author(20)), INDEX(title(20)), INDEX(category(4)), INDEX(year), PRIMARY KEY (isbn)) ENGINE InnoDB; INSERT INTO classics VALUES ('I', 'Above Sky', 'Aviation', '2099', '846533884'); SELECT * FROM classics;

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

Copy Clear
Copy Format Clear
<?php // login.php $query = "SELECT * FROM classics"; $result = $pdo->query($query); if (!$result) die("Fatal Error"); $rows = $result->num_rows; for ($j = 0 ; $j < $rows ; ++$j) { $rows = $result->num_rows; for ($j = 0 ; $j < $rows ; ++$j) { $result->data_seek($j); echo 'Author: ' .htmlspecialchars($result->fetch_assoc()['author']) .'<br>'; $result->data_seek($j); echo 'Title: ' .htmlspecialchars($result->fetch_assoc()['title']) .'<br>'; $result->data_seek($j); echo 'Category: '.htmlspecialchars($result->fetch_assoc()['category']).'<br>'; $result->data_seek($j); echo 'Year: ' .htmlspecialchars($result->fetch_assoc()['year']) .'<br>'; $result->data_seek($j); echo 'ISBN: ' .htmlspecialchars($result->fetch_assoc()['isbn']) .'<br><br>'; } $result->close(); $connection->close(); } //$result->close(); //$pdo->close(); ?>
Copy Clear