PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
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;
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(); ?>
Show:  
Copy Clear