Location: PHPKode > scripts > phpRetrieve > phpRetrieve/viewRun.php
<?php
	
	Include('getMySQL.php');
	
	$myQuery = str_replace("SELECT", "SELECT SQL_CALC_FOUND_ROWS", $myQuery)." Limit 0, ".$maxRecords;
	//$result = mysql_query($myQuery) or die ("Error in query. ".mysql_error(). "<br/><br/>".$myQuery); 
	$result = mysql_query($myQuery) or die (header('Location: index.php?view=SQL&msg=Error in query '.mysql_error())); 
	$num=mysql_numrows($result);
	
	$countResult = mysql_query("SELECT FOUND_ROWS() As Found");
	$countNum=mysql_numrows($countResult);
	$Found = 0;
	if($countNum > 0){ $Found = mysql_result($countResult,0,'Found'); }
	
	$confirm = "";
	if($Found > $maxOutputs){
		$confirm = "onclick=\"return confirm('Export data is limited to $maxOutputs records. This is a configuration setting. Continue anyway?')\"";
	}
	
	
?>

	
	<div id="main" >
			<?php
		
				if($manualQuery == ""){
					echo "&nbsp;&nbsp;<a class=\"button\" href=\"javascript: window.location='index.php?view=Design'\"  title=\"Show Design\" ><span><b>Design</b></span></a>";
				}
				
			?>
		&nbsp;&nbsp;<a class="button" href="javascript: window.location='index.php?view=SQL'"  title="Show MySQL" ><span><b>Show MySQL</b></span></a>
		&nbsp;&nbsp;<a class="button" href="javascript: window.location='exportCSV.php'"  title="Export data to csv file" <?php echo $confirm; ?> ><span><b>Export CSV</b></span></a>
		&nbsp;&nbsp;<a class="button" href="javascript: window.location='exportXML.php'"  title="Export data to xml file" <?php echo $confirm; ?> ><span><b>Export XML</b></span></a>
		&nbsp;&nbsp;<a class="button" href="javascript: window.location='index.php?view=Save'"  title="Save Query" ><span><b>Save</b></span></a>
		<div class="clear"></div>
		<div>
		Showing <?php echo number_format($num); ?> of <?php echo number_format($Found); ?> Records from table '<?php echo $tbl; ?>'<br /><br />
		
		<?php
		
		$m = mysql_num_fields($result);
		$wdth = $m * 150;
		echo "<table style='width: ".$wdth."px;'>";

		//Get Field Names
		$j = 0;
		echo "<tr>";
		while ($j < $m) {
			$meta = mysql_fetch_field($result, $j);
			$fieldName = $meta->name;
			$fieldName = str_replace("_", " ", $fieldName);
			$j++;
			echo "<th> <b> $fieldName </b> </th>";
		}
		echo "</tr>";
		
		//Now Get data
		$i = 0;
		$end = $num;
		while ($i < $end){

			//Loop field names
			echo "<tr>";
			$j = 0;
			while ($j < $m) {
				$meta = mysql_fetch_field($result, $j);
				$field = $meta->name;
				$vl = mysql_result($result,$i,$field);
				echo "<td ><b>".htmlentities($vl, ENT_QUOTES)."</b>&nbsp;</td>";
				$j++;
			}
			echo"</tr>";
			$i++;
		}	
		
		
		echo "</table>";
		
		?>
		
		</div>
		
	</div>
	
Return current item: phpRetrieve