Location: PHPKode > scripts > phpRetrieve > phpRetrieve/index.php
<?php
session_start();

	//$_SESSION['session_Table'];
	
	//Link to server
	include('config.php');

	//connect to the databaser
	mysql_connect('localhost',$user,$password);
	@mysql_select_db($database) or die( "Unable to select database");

	$rc = 0;
	$fld_result = "";
	$viewFields = "Y";
	$currentUser = $dfUser;
	
	if(isset($_SESSION['session_viewFields'])){$viewFields = $_SESSION['session_viewFields']; }
	if(isset($_SESSION['session_currentUser'])){$currentUser = $_SESSION['session_currentUser']; }

	include('setUser.php');
	$_SESSION['session_currentUser'] = $currentUser;
	
	$tbl = "";
	if(isset($_SESSION['session_Table'])){$tbl = $_SESSION['session_Table']; }
	
	if(isset($_GET['navView'])){
		$_SESSION['session_navView'] = $_GET['navView'];
	}
	
	
	if(isset($_GET['tbl'])){
		if($tbl != $_GET['tbl']){
			$tbl = $_GET['tbl'];
			$viewFields = "Y";
			unset($_SESSION['session_Criteria']);
			unset($_SESSION['session_Query']);
			$_SESSION['session_View'] = "Design";
			
			//reset report variables
			$_SESSION['session_rptOwner'] = $currentUser;
			$_SESSION['session_rptBuild'] = $build;
			$_SESSION['session_rptDate'] = date("Y-m-d");
			$_SESSION['session_rptName'] = "Report_".strtotime(date("Y-m-d H:i:s"));
			$_SESSION['session_rptDatabase'] = $database;
			$_SESSION['session_rptShare'] = "No";
			$_SESSION['session_rptTable'] = $tbl;
			
		}
		else {
			if($viewFields == "Y"){
				$viewFields = "N";
			}
			else {
				$viewFields = "Y";
			}
		}
	}
	$_SESSION['session_Table'] = $tbl;
	$_SESSION['session_viewFields'] = $viewFields;
	
	if(isset($_GET['view'])){
		$view = $_GET['view'];
		unset($_SESSION['session_View']);
	}
	else {
		$view = "Design";
		if(isset($_SESSION['session_View'])){$view = $_SESSION['session_View']; }
	}
		
	if($tbl != ""){
		$fld_result = mysql_query("SHOW COLUMNS FROM ".$tbl);
		$rc_result = mysql_query("Select Count(1) As RC From ".$tbl);
		$rc_num=mysql_numrows($rc_result);
		if($rc_num > 0){ $rc = number_format(mysql_result($rc_result,0,'RC'),0); }
	}

	if(isset($_SESSION['session_Criteria'])){
		$arr = $_SESSION['session_Criteria'];
	}

	$manualQuery = "";
	if(isset($_SESSION['session_Query'])){
		$manualQuery = $_SESSION['session_Query'];
	}
	
	if($manualQuery != "" && $view == "Design") {
		$view = "SQL";
	}
	$_SESSION['session_View'] = $view;

	//initialise report variables
	if(!isset($_SESSION['session_rptName'])){
		$_SESSION['session_rptOwner'] = $currentUser;
		$_SESSION['session_rptBuild'] = $build;
		$_SESSION['session_rptDate'] = date("Y-m-d");
		$_SESSION['session_rptName'] = "Report_".strtotime(date("Y-m-d H:i:s"));
		$_SESSION['session_rptDatabase'] = $database;
		$_SESSION['session_rptShare'] = "No";
		$_SESSION['session_rptTable'] = $tbl;
	}
	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>
<head>
<link rel="stylesheet" type="text/css" href="query.css">
<script type="text/javascript" src="report.js"></script>

</head>
<body>
<div id="wrapper">
<div id="header">
	
	<b><a href="http://www.phpretrieve.com/index.html" target="_blank" style="color: #fff;"><?php echo $appTitle; ?></a></b>
	<b>&nbsp;&nbsp;&nbsp; | &nbsp;&nbsp;&nbsp;<a href="http://www.phpretrieve.com/help.html" target="_blank" style="color: #fff;">Help</a> </b>
	<?php
	
		if($view == "Design"){
			echo "<b>&nbsp;&nbsp;&nbsp; | &nbsp;&nbsp;&nbsp;<i>Design View</i> </b>";
		}
		if($view == "SQL"){
			echo "<b>&nbsp;&nbsp;&nbsp; | &nbsp;&nbsp;&nbsp;<i>MySQL View</i> </b>";
		}
		if($view == "Run"){
			echo "<b>&nbsp;&nbsp;&nbsp; | &nbsp;&nbsp;&nbsp;<i>Run Query</i> </b>";
		}
		if($view == "Save"){
			echo "<b>&nbsp;&nbsp;&nbsp; | &nbsp;&nbsp;&nbsp;<i>Save Query</i> </b>";
		}
	
	?>
	
</div>

		
	<?php
	
		if($view == "Design"){
			Include('viewDesign.php');
		}
		if($view == "SQL"){
			Include('viewQuery.php');
		}
		if($view == "Run"){
			Include('viewRun.php');
		}
		if($view == "Save"){
			Include('viewSave.php');
		}
		
	?>
		

<div id="footer">
	<i>User : <?php echo $currentUser; ?> &nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp; Report : <?php echo $_SESSION['session_rptName']; ?></i> 
</div>
</div>

</body>
	
	<script type="text/javascript">

		function rsz(){
			ht = document.documentElement.clientHeight;
			try{ document.getElementById('left').style.height = (ht -100)+"px"; }catch(error){}
			try{ document.getElementById('right').style.height = (ht -100)+"px"; }catch(error){}
			try{ document.getElementById('main').style.height = (ht -100)+"px"; }catch(error){}
		}
		rsz();
		document.body.onresize = function (){
			rsz();
		}
		
	</script>
		<?php
		
			if(isset($_GET['msg'])){
				echo "	<script>
							alert(\"".$_GET['msg']."\");
						</script> ";
			}
		
		?>
</html>
Return current item: phpRetrieve