Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.
Quick and Dirty MySQL DB Preview - PHP Code Bank
Quick and Dirty MySQL DB Preview
This is a quick and dirty script I cooked up for previewing a site's MySQL database in the event that I do not have CPanel or command-line access (but FTP access is available).
<?php
// Specify DB connect include / code here
include 'connect.php';
// End DB connect code
// Specify initial HTML and HEAD include / code here
// Get all the table names
if ($result1 = mysql_query("SHOW TABLES")) { while ($row1 = mysql_fetch_array($result1)) {
echo '<table>';
// Get the table fields for each table and make the HTML table headings
if ($result2 = mysql_query("DESCRIBE ".$row1[0])) { while ($row2 = mysql_fetch_array($result2)) { echo '<th>'.$row2[0].'</th>'; } }
// Get the each table's contents
if ($result3 = mysql_query("SELECT * FROM ".$row1[0]." LIMIT 10")) { while ($row3 = mysql_fetch_array($result3)) {
echo '<tr>';
$count = count($row3);
for ($x = 0; $x < $count; $x++) { echo '<td>'.$row3[$x].'</td>'; }
echo '</tr>';
} } echo '</table>'; } }
?>
Comments
killgooglecom 11 years ago
Um, you should just implement the connect.php part right in it because some people may be confused… Other wise good job!