Skip to content

Instantly share code, notes, and snippets.

@umairidrees
Last active December 22, 2015 01:59
Show Gist options
  • Save umairidrees/6400387 to your computer and use it in GitHub Desktop.
Save umairidrees/6400387 to your computer and use it in GitHub Desktop.
just copy that table. and add database table name. and all data will be available for you on your page from database.
<?php
$username="root"; $password=""; $database="exam_codes";
$con = mysql_connect("localhost",$username,$password) or die( "Unable to Connect database");
mysql_select_db($database,$con) or die( "Unable to select database");
$ShowTable = "blogs";
$sql = mysql_query("SELECT * FROM `$ShowTable` LIMIT 11");
$row = mysql_fetch_assoc($sql);
// show headings alon
echo "<table class='table table-striped'><tr><th>No</th>";
foreach($row as $name => $value){
echo '<th>'.$name.'</th>';
}
echo "</tr>";
// show all records without headings
while($row = mysql_fetch_assoc($sql)){
echo "<tr>";
foreach($row as $name => $value){
echo '<td>'.$value.'</td>';
}
echo "</tr>";
}
echo "</table>";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment