Location: PHPKode > scripts > MySql database query tool > HDBQ_2_1/index.php
<?php
include "authheader.php";
if($block == false){
?>

<html>
<head>
<?php
	$type=$_POST['type'];
	$radioo=$_POST['rb1'];
	$qtext = $_POST['qtext'];
	$qtext = str_replace("\\","",$qtext);
	$user = $_POST['user'];
	$pass = $_POST['pass'];
	$host = $_POST['host'];
	$dbn = $_POST['dbname'];
	include './config.php';
	$dho = $hostname;
	$dus = $username;
	$dpa = $password;
	$ddb = $dbname;

	if($user != "" && $host != "" && $dbn != "")
	{
		$hostname = $host;
		$username = $user;
		$password = $pass;
		$dbname = $dbn;
	}
	$db = @mysql_connect($hostname, $username,$password);
	if(!$db)
		$con = "conf";
	else if(!@mysql_select_db($dbname,$db))
		$con = "dbnf";

	include "queries.php";

	$total = count($query);
	$half = round($total/2);
	echo "<script language=javascript>";
	echo "var quer =  Array;\n";
	for($xxy = 0; $xxy < $total; $xxy++)
	{
		$qqqu = html_entity_decode($query[$xxy], ENT_QUOTES);
		$qqqu = str_replace('"','\"',$qqqu);
		//$qqqu = str_replace('XXDATE','"+date+"',$qqqu);
		echo "quer[$xxy] = \"".$qqqu."\";\n";
	}
	echo "</script>";
	include "header.php";
?>


<script language=javascript>
function changae()
{
	var ss = document.ssd.dd.value;
 	document.form15.qtext.value = ss;
}

function changab(ddc, ddate)
{
	document.form15.rb1.value=ddc;
	var ss = "";
	var dat = new Date();

	if(!isNaN(ddc)){
		var sss = eval("document.xxx.rb1["+ddc+"]");

		if(ddate == "today"){
			var year = dat.getFullYear();
			var month = parseInt(dat.getMonth())+1;
			var dax = year+"-"+month+"-"+dat.getDate();
		}else{
			var dax = ddate;
		}
		var queer  = quer[ddc].replace('XXDATE',dax);
		document.form15.qtext.value = queer;
	}else{
			 document.form15.qtext.value = " ";
	}
}

function setdate()
{
	var sdate = document.xxx.d1.value;
	var sss = eval("document.xxx.rb1");
	for(var y=0; y<sss.length; y++)
	{
		if(sss[y].checked == true){
			changab(y,sdate);
		}			
	}

}

function confirmDel()
{
	document.form15.user.value = document.f14.un.value;
	document.form15.pass.value = document.f14.pw.value;
	document.form15.host.value = document.f14.hn.value;
	document.form15.dbname.value = document.f14.dbn.value;
	var sss = document.form15.qtext.value;
	if(sss.indexOf("delete") != -1   ||  sss.indexOf("alter") != -1)
	{
		var dd = confirm("You are trying to do a delete or modify operation, press ok to continue.");
		if(dd == true)
			return true;
		else
			return false;
	}
}

function changedef()
{
	document.f14.hn.value = document.f14.hh.value;
	document.f14.un.value = document.f14.uu.value;
	document.f14.pw.value = document.f14.pp.value;
	document.f14.dbn.value = document.f14.dd.value;
}
</script>

<tr bgcolor=#fefefe height=100%><td width=100% align=center valign=top>
<br>
	<table cellpadding=0 cellspacing=1 align=center style="background-color: #33778a; 
padding: 3px; font-family: arial, verdana, san-serif;" border=0>
	<tr><td bgcolor=#dddddd align=center>
	<form name=f14 onsubmit="return false">
     	<input type=hidden name=def value=def onclick="changedef()"></input>
	<input size=10 type=hidden name=hn value="<?php echo($hostname); ?>"></input>
	<input size=10 type=hidden name=dbn value="<?php echo($dbname); ?>"></input>
	<input size=10 type=hidden name=un value="<?php echo($username); ?>"></input>
	<input size=10 type=hidden name=pw value="<?php echo($password); ?>"></input>
	<input type=hidden name=uu value="<?php echo($dus); ?>"></input>
	<input type=hidden name=pp value="<?php echo($dpa); ?>"></input>
	<input type=hidden name=dd value="<?php echo($ddb); ?>"></input>
	<input type=hidden name=hh value="<?php echo($dho); ?>"></input></form>

	<form name=ssd style="font-size: 14px; padding: 0px; margin: 0px;">
	<select name=dd onchange="changae()" size=2 style="width:410px;">
	<option value="select * from ">select * from </option>
	<option value="select count(*) from ">select count(*) from </option>
	<option value="show tables">show tables</option>
	<option value="show databases">show databases</option>
	<option value="insert in to ">insert in to </option>
	<option value="desc">desc</option>
	</select><br>
	</form>
	
	<form name=xxx action="#" method="get" style="font-size: 14px; padding: 0px; border: 0px; margin: 0px;">
	<?php
		echo "<table align=center cellpadding=0 cellspacing=0 style=\"font-size: 13px;\" ><tr align=left><td>";
		for($dfd=0; $dfd < count($query); $dfd++){
	
			if($radioo == $dfd && $radioo != null)
				echo "<input name=rb1 type=radio checked=true onMouseUp=\"changab($dfd,'today')\"> $name[$dfd] <br>";
			else
				echo "<input name=rb1 type=radio onMouseUp=\"changab($dfd,'today')\"> $name[$dfd] <br>";
			if($dfd >= 1 && $dfd == ($half-1)){
				echo "</td><td valign=top>";
			}
		}
		echo "</td></tr></table>";
	?>

	Date: <input name="d1" id="f_date_a" readonly="1" type="text" onchange="setdate()">
	<img src="img.gif" id="f_trigger_a" style="cursor: pointer; border: 1px solid red;" title="Date selector"
	      onmouseover="this.style.background='red';" onmouseout="this.style.background=''" />
	</form>

	<script type="text/javascript">
	    Calendar.setup({
	        inputField     :    "f_date_a",     // id of the input field
	        ifFormat       :    "%Y-%m-%d", // format of the input field
	        button         :    "f_trigger_a",  // trigger for the calendar (button ID)
	        align          :    "Tl",    // alignment (defaults to "Bl")
	        singleClick    :    true
	    });
	</script>

	<div align=right style="font-size: 12px;"><a href="update.php">Manage Queries</a></div>
	</td></tr>
	<tr><td>
	<br>
	<form name="form15" method="post" action="index.php" onsubmit="return confirmDel()">
	<input type="hidden" name="rb1">
	<input type="hidden" name="user"  value="<?php echo($username);?>">
	<input type="hidden" name="pass" value="<?php echo($password);?>" >
	<input type="hidden" name="host" value="<?php echo($hostname);?>" >
	<input type="hidden" name="dbname" value="<?php echo($dbname);?>" >
	<input type="hidden" name="type" value="query" >
	<textarea name="qtext" value="<?php echo($qtext);?>" rows=4 cols=55><?php echo($qtext);?></textarea>
	<input type="Submit" name="submit" value="Go">
	</form>
	</td></tr></table>
	<br><br>

<?php
include "footer.php";
}
?>
Return current item: MySql database query tool