Location: PHPKode > scripts > MySql database query tool > HDBQ_2_1/show-result.php
<table width=80% align=center><tr><td style="font-size: 12px; font-family: verdana, arial;" align=center>
<?php
if($con == "dbnf")
	echo "<font color=red>Wrong database name<br></font>";

if($con == "conf")
	echo "<font color=red>Connection Failed<br></font>";
else if($type =="query")
{
	$qtext2 = str_replace("\\", " ", $qtext);
	if($qtext2 == "")
	{
		echo "Please enter a proper query";
	}	
	else
	{
		if($result = mysql_query("$qtext2",$db))
			echo "Successly Exected - ";
		else
			echo "<font color=red>Not able to execute the query<br>Either the 
				table doesnot exist or a wrong query.</font><br><br>";

		echo("<div align=left style=\"padding-left: 30px;\">Query is : <font color=blue>".$qtext2."</div></font>");

		echo "<table border=1 cellpadding=0 cellspacing=0 style=\"font-size: 14px; font-family: arial;\"> 
		<tr bgcolor=#aaffaa align=center style=\"font-weight: none;\">\n";

		$sds = @mysql_num_fields($result);
		for($ss=0; $ss<$sds; $ss++)
		{
			$ee = @mysql_field_name($result,$ss);
			echo "<td>$ee</td>";		
		}
	   	echo "</tr>\n";

		$vv = true;
		while ($line = @mysql_fetch_array($result, MYSQL_ASSOC)) {
			if($vv === true){
	   		echo "<tr align=center bgcolor=#ffeeff>\n";
			$vv = false;
			}
			else{
		   	echo "<tr align=center bgcolor=#ffccff>\n";
			$vv = true;
			}
		  	foreach ($line as $col_value) {
       		echo "<td>$col_value</td>\n";
   			}
	   	echo "</tr>\n";
		}
		echo "</table>\n";
		/* Free resultset */
		@mysql_free_result($result);
	}
}
?>
</td></tr></table>
Return current item: MySql database query tool