Created
June 21, 2016 18:04
-
-
Save vigikaran/22b2c9d38a1b65970d072ac7e1341031 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Make a MySQL Connection | |
mysql_connect("host", "user", "password") or die(mysql_error()); | |
mysql_select_db("database") or die(mysql_error()); | |
// Get all the data from the "example" table | |
$result = mysql_query("SELECT * FROM news LIMIT 5") | |
or die(mysql_error()); | |
echo "<table border='1'>"; | |
echo "<tr> <th>ID</th> <th>Title</th> </tr>"; | |
// keeps getting the next row until there are no more to get | |
while($row = mysql_fetch_array( $result )) { | |
// Print out the contents of each row into a table | |
echo "<tr><td>"; | |
echo $row['news_id']; | |
echo "</td><td>"; | |
echo $row['news_title']; | |
echo "</td></tr>"; | |
} | |
echo "</table>"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment