PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE Persons ( PersonID int, LastName varchar(255), FirstName varchar(255) ); INSERT INTO Persons VALUES (1, 'Svensson', 'Anders'); SELECT * FROM Persons;
Copy Clear
Copy Format Clear
<?php $query = "SELECT * FROM Persons;"; // Run query using mysqli $result = $mysqli->query($query); $data = $result->fetch_assoc(); print("Efternamn: {$data['LastName']}"); print( "\n"); print($result->num_rows); print( "\n"); print(gettype($result)); print( "\n"); echo '<pre>'; print_r($result); echo '</pre>'; print( "\n"); echo "<table>"; while($row = mysqli_fetch_array($result)){ //Creates a loop to loop through results print($row[0]); echo "<tr><td>" . htmlspecialchars($row[0]) . "</td><td>" . htmlspecialchars($row[1]) . "</td></tr>"; //$row['index'] the index here is a field name print( "\n"); } echo "</table>"; //Close the table in HTML //mysql_close(); //Make sure to close out the database connection
Show:  
Copy Clear