PHPBuilder - Check your MySQL tables via WAP



RSS Twitter
Tips Application Architecture

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: http://www.mildewhall.com/nowhere/DBlist.jpg


<?php 
header("Content-type: text/vnd.wap.wml"); 
echo "<?xml version=\"1.0\"?>";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\"" 
	. " \"http://www.wapforum.org/DTD/wml_1.1.xml\">"; 
?>
<wml>
<template>
	<do type="prev" label="Previous">
		<prev/>
	</do>
</template>    
<card id="card2" title="DB Listing">

<?php include 'SELECT_connector.inc'; 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.

Author:
Peter Garner

Comment:



Comment:

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