Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
mysqladmin -h <yr server> -p <ur passwd> variables | grep data
<?
// GENERIC OPEN DATABASE FUNCTION --------------------------------------------
function open_db() {
$dblink = mysql_connect($GLOBALS["dbhost"], $GLOBALS["dbuser"], $GLOBALS["dbpassw"]);
mysql_select_db($GLOBALS["dbname"], $dblink);
return $dblink;
}
// CREATE TEST TABLE FUNCTION ------------------------------------------------
function newTable($dbName) {
$dblink = open_db();
echo "Creating test table <B>$dbName</B><BR>";
$res = mysql_query("CREATE TABLE $dbName (id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id))");
if(!$res)
echo "Fejl : ".mysql_error();
else
echo "<B>$dbName</B> is created<BR><BR>";
mysql_close($dblink);
}
// CREATE A BUNCH OF TEST TABLES FUNCTION ------------------------------------
function createTestTables() {
newTable("test1");
newTable("test2");
newTable("test3");
}
// DROP ALL TABLES FUNCTION --------------------------------------------------
function dropAllTables($dbname) {
// fetch table names into $tableNames array
$result = mysql_list_tables($dbname);
if (!$result) {
echo "DB Error, could not list tables\n";
echo 'MySQL Error: ' . mysql_error();
exit;
}
while ($row = mysql_fetch_row($result)) {
$tableNames[] = $row[0];
}
mysql_free_result($result);
// table names fetched
// build SQL "DROP" string
$drop = "DROP TABLE ";
for($tableCount=0;$tableCount<count($tableNames);$tableCount++) {
$drop .= $tableNames[$tableCount];
if($tableCount<count($tableNames)-1) // only add a comma if not last table!
$drop .= ",";
}
// DROP string, $drop, is build ...
// ... now, drop all tables:
$dblink = open_db();
$result = mysql_query($drop)
or die("Invalid query: " . mysql_error());
mysql_close($dblink);
echo "All tables in $dbname are dropped!";
}
// MAIN ----------------------------------------------------------------------
$dbhost = "localhost";
$dbname = "test";
$dbuser = "******";
$dbpassw = "******";
$mode = "make";
switch($mode) {
case "make" : createTestTables();
break;
case "drop" : dropAllTables("test");
break;
}
?>