Location: PHPKode > projects > HypatiaDB > hypatiadb/sqlbrowse.php
<?php

include("common_db.php");
include("functions.php");
dbconnect($host, $username, $password);
$strings = loadStrings($lang, 'SQLB');
headers();
html();
head($strings['SQLB_TITLE']);
menu();
navpane();

$query = $_REQUEST['query'];

if(isset($_REQUEST['database'])) {
	$db = $_REQUEST['database'];
} else {
	if($_SESSION['current_db'] != '') {
		$db = $_SESSION['current_db'];
	} else {
		$db = '';		//we can press on anyway, because some queries don't require a database
	}
}

//The $favourite variable will contain the SQL query of the current table browse if the user
//adds the current table browse to their favourites.
//TODO: CHECK
if(isset($_REQUEST['favourite'])) {
	$favourite = $_REQUEST['favourite'];
} else {
	$favourite = '';
}

if($favourite != '')
   $query = $favourite;

//Get the current users status
$user_status = get_currentuser_status();


if($db != '') {				//some queries, of course, don't require a database
	mysql_select_db($db) or $error = (sprintf($strings['SQLB_ERR_BADDB'], mysql_error()));
}


($result = mysql_query("$query")) or $error = (sprintf($strings['SQLB_ERR_QUERY'], $query, mysql_error()));

//if the $favourites variable is not an empty string, then 'normal_browse.php' has made a self
//referential call through a form via the code located at the bottom of this file. This form
//is used if the user wishes to submit the current browse results to their favourites. 
if($favourite != '') {
	mysql_select_db('HypatiaDB') or die("couldn't select database HypatiaDB");

	$current_user = $_SESSION['session_user']; 

	//prepare the favourite for inclusion into mysql
	$favourite = addslashes($favourite);

	$fav_name = $_GET['fav_name']; 


	$insert_favourite_query = "INSERT INTO favourites VALUES('$current_user', '$favourite', '$fav_name', '$db')";
	mysql_query($insert_favourite_query);
}

echo('<div id="mainpane">');

if(isset($error)) {
	echo('<p class="error">' . $error . '</p>');
} else {
	print_query_results_func($result);
}

echo('</div>');

endhtml();

?>
Return current item: HypatiaDB