Location: PHPKode > scripts > phpRetrieve > phpRetrieve/Copy of index.php
<?php

	//Link to server
	include('database.php');

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

	//Get list of tables
	$tbl_result = mysql_query("SHOW TABLE STATUS FROM $database");
	//Tables to exclude
	$exclude = array();
	$exclude['users'] = True;
	
	$rc = 0;
	$fld_result = "";
	if(isset($_GET['tbl'])){
		$tbl = $_GET['tbl'];
		$fld_result = mysql_query("SHOW COLUMNS FROM ".$tbl);
		//Get record count
		//$rc = 0;
		$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); }
	}
	else {
		$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">

	 	function secondField(opt, scndID){

			if(opt == "bt"){
				document.getElementById(scndID).style.display = '';
			}
			else {
				document.getElementById(scndID).style.display = 'none';
			}
		}

	</script>

</head>
<body>
<div id="wrapper">
<div id="header">
	
	Header
</div>
<div id="left" >

			<div >
				<a class="button" href="ex.html" onclick="this.blur();" title="Switch to Table view" ><span><b>Tables</b></span></a>
				<a class="button" href="ex.html" onclick="this.blur();" title="Switch to Report view"><span><b>Reports</b></span></a>
			</div>
			<br /><br />
				
			<?php
				
				//List tables
				if (!$tbl_result) {
					echo "No tables found.\n";
				}
				else {
					while ($array = mysql_fetch_array($tbl_result)) {
						$tblNm = $array['Name'];
						if(!isset($exclude[$tbl])){
							$rowCount = number_format($array['Rows'],0);
							$comment = $array['Comment'];
							echo "<a href=\"?tbl=".$tblNm."\" title=\"".$comment." ".$rowCount." records\">
									<img src=\"table.jpg\" style=\"border: none;\" />&nbsp;".$tblNm."</a><br /> \n";
						}
					}
				}

			?>
			
</div>
<div id="right" >
		
		<br /><br />
		&nbsp;&nbsp;<small>Table contains <?php echo $rc; ?> records.</small>
		<form>
		<table>
			<tr><th style="width:120px;">Field</th><th style="width:100px;">Type</th><th style="width:50px;">Select</th><th style="width:100px;">Condition</th><th style="width:150px;" colspan="2">Criteria</th><th style="width:100px;" >Runtime Filter</th></tr>
			<?php
				
				//Show filed information
				$i = 0;
				if($tbl != ""){
					while ($array = mysql_fetch_array($fld_result)) {
						$i++;
						$fld = $array['Field'];
						$tpe = $array['Type'];
						echo "<tr><td>".$fld."<input type='hidden' value='$fld' name='".$i."_field'></td>
									<td>".$tpe."</td>
									<td style='text-align: center;'><input type='checkbox' name='".$i."_include' value='yes' Checked=Checked/></td>
									<td style='text-align: center;'>
										<select name='".$i."_condition' onchange=\"secondField(this.options[this.selectedIndex].value, '".$i."_Val2')\">
											<option value='eq'>=</option>
											<option value='gt'>&gt;</option>
											<option value='lt'>&lt;</option>
											<option value='ge'>&gt;=</option>
											<option value='le'>&lt;=</option>
											<option value='lk'>Like</option>
											<option value='bt'>Between</option>
											<option value='in'>In</option>
										</select>
									</td>
									<td style='text-align: center;'>
										<input id='".$i."_Val1' type='text' Size='12' />									
									</td>
									<td style='text-align: center;'>
										<input id='".$i."_Val2' style='display: none;' type='text' Size='12' />									
									</td>
									<td style='text-align: center;'><input type='checkbox' name='".$i."_filter' value='yes'/></td>
									</tr> ";
					}
				}
			?>
			
		</table>
		<input name="filedcount" value="<?php echo $i; ?>" type="hidden" />
		</form>

</div>
<div id="footer"><a id="min" href="#" onclick="minLeft();">[Min data source]</a><a id="max" href="#" onclick="maxLeft();"></a></div>
</div>
</body>
	
	<script type="text/javascript">

		function rsz(){
			ht = document.documentElement.clientHeight;
			document.getElementById('left').style.height = (ht -140)+"px";
			document.getElementById('right').style.height = (ht -140)+"px";
		}
		rsz();
		document.body.onresize = function (){
			rsz();
		}
		function minLeft(){
			document.getElementById('left').style.width = "0px";
			document.getElementById('left').style.display = "none";
			document.getElementById('right').style.marginLeft = "0px";
			document.getElementById('min').innerHTML="";
			document.getElementById('max').innerHTML="Max data source";
		}
		function maxLeft(){
			document.getElementById('left').style.width = "250px";
			document.getElementById('left').style.display = "block";
			document.getElementById('right').style.marginLeft = "168px";
			document.getElementById('min').innerHTML="Min data source";
			document.getElementById('max').innerHTML="";
		}
	</script>

</html>
Return current item: phpRetrieve