PHPBuilder - Check your MySQL tables via WAP

RSS Twitter

Check your MySQL tables via WAP

by: Peter Garner
June 10, 2003

If you want to run a quick check on how many records are held in various tables on your MySQL database, here's how you can do it via your WAP phone.

Effectively, you connect to the database, and run a "SHOW TABLES" query. You then loop through the list of tables and for each one run another query "SELECT COUNT(*) FROM ...".

The results are formatted nicely in a table, if your phone supports it. I use this to find out if particular tables have been updated since I last checked. Enjoy !

You can see a screenshot here:

header("Content-type: text/vnd.wap.wml"); 
echo "<?xml version=\"1.0\"?>";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\"" 
	. " \"";" target="_blank" target="_new">\">"; 
	<do type="prev" label="Previous">
<card id="card2" title="DB Listing">

<?php include ''; mysql_connect("localhost", $DBUSER,$DBPASS); mysql_select_db("yourdatabase"); $query = "SHOW TABLES"; $result = mysql_query($query); $nr = mysql_num_rows($result); if ( $nr > 0 ) { $pointer++; print "<table columns=\"2\">"; while ( $row = mysql_fetch_array($result) ) { $resultc = mysql_query("SELECT COUNT(*) FROM $row[0]"); $cnt = mysql_fetch_array($resultc); print "<tr>"; print "<td>" . $row[0] . "</td><td>" . $cnt[0] . "</td>"; print "</tr>"; } print "</table>"; } @mysql_close(); ?> <small> <anchor>Main <go href="index.wml"/> </anchor> </small>

</card> </wml>

Comment and Contribute

Your comment has been submitted and is pending approval.

Peter Garner



(Maximum characters: 1200). You have characters left.