Location: PHPKode > projects > HypatiaDB > hypatiadb/left.php

/* HypatiaDB - Easy to use web-based database management system. Written primarily in PHP using  * the MySQL database engine.
 * Copyright (C) 2004 Simon D'Alfonso
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

header("Cache-control: private"); // IE 6 Fix. 


//The $db varibale is passed by a drop-down menu listing all the available databases.
//This menu is contained within a form which makes a self-referential call to left.php
//The call is activated when a database is selected from the drop-down menu. 

$db = $_GET['database'];

mysql_connect($host, $username, $password) or die("Couldn't connect to $host");

//If the following condition is met, then a database has been selected. The body of this
//conditional statement firstly updates the session
//currently selected database. Secondly it obtains a listing of the tables of the selected 
//database and stores it as a mysql_query in $tbls_result.

if($db != "")
   $_SESSION['current_db'] = $db; 	
   mysql_select_db($db) or die("Couldn't select database $db");
   $tbls_query = "SHOW TABLES";
   ($tbls_result = mysql_query($tbls_query)) or die ("$tbls_result query unsuccessful");

$databases_query = "SHOW DATABASES";
($databases_result = mysql_query($databases_query)) or die ("$databases_query query unsuccessful");


<TITLE>Select a Database</TITLE>


   background-color: rgb(214,211,206);
   position: absolute;
   top: 0;
   left: 0;
   height: 15;
   z-index: 1;
   padding: 4px;

A:link {color:black; text-decoration:none}

A:visited {color:black; text-decoration:none}

A:hover {color:blue; text-decoration:none}

A:active {text-decoration:none}



function init()
      screenWidth = document.body.clientWidth;
      document.getElementById('menuBar').style.width = screenWidth;
      screenWidth = innerWidth;
      document.getElementById('menuBar').style.width = screenWidth-8;

var selectedTable = '';

function highlightSelectedTable(tblID)
   document.getElementById(tblID).style.color = 'blue';

   if(selectedTable != '')
      document.getElementById(selectedTable).style.color = 'black';	
   selectedTable = tblID;





//If a database has been selected, then reload the body frame to body, so 
//that the menu options to create tables and delete databases are provided.

   if($db != "")
      echo "<BODY onLoad=\"javascript:parent.body.document.location.href='body.php?database=$db'; init()\">";
      echo "<BODY onLoad='init()'>";


<div ID='menuBar' CLASS='menuBar'></div>



echo "<P align='center' STYLE='font-size: 10pt'>Welcome <B>".$_SESSION['session_user']."</B></P>";	

// Echo out the form that contains a drop-down menu with a listing of all the available
// databases.

echo "<P ALIGN='left'>";
echo "<FORM ACTION='left.php' METHOD=GET>";
echo "<P ALIGN='center'>".print_databases_dropdown_func("dynamic", $db)."</P>";
echo "<INPUT TYPE='hidden' NAME='status' VALUE='${status}'>";
echo "</FORM>";
echo "</P>";

// If a database has been selected, echo a listing of all of its tables.
$tbl_number = 0;

if($db != "")
   echo "<P ALIGN='left'>&nbsp;<FONT STYLE=\"font-weight:bold; font-size:14pt; text-decoration:underline\">Tables</FONT><BR>";
   while ($row = mysql_fetch_array($tbls_result))
         echo "&nbsp;&#149
<A HREF=\"normal_browse.php?table=".$row[0]."&database=".$db."\"
onClick=\"javascript:highlightSelectedTable('tbl${tbl_number}')\" TARGET='body'>" . $row[0] . "</A><BR>";
   echo "</P>";


Return current item: HypatiaDB