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

<html>
<head>

<?php
include "header.php";
?>

<tr bgcolor=#ffffff height=100%>
<td width=100% align=center valign=top>

<br>
<table cellpadding=2 cellspacing=1 align=center style="background-color: #ffffff; 
font-size: 13px; font-family: arial, verdana, san-serif;" border=0>
<?php
	include "queries.php";

	$position = $_POST['position'];
	$delete = $_POST['delete'];
	$namea = $_POST['namea'];
	$querya = $_POST['querya'];

	$querya = str_replace("\\","",$querya);
	$querya = htmlspecialchars($querya,ENT_QUOTES);
	$namea = str_replace("\\","",$namea);
	$namea = htmlspecialchars($namea,ENT_QUOTES);

	if($delete == "yes")
	{
		$open = fopen("queries.php","w");
		fwrite($open,"<?php \n\n");
		
		$xx = 0;
		for($dfd=0; $dfd < count($query); $dfd++){
			if($dfd != $position){
				fwrite($open,"$"."name[$xx] = \"$name[$dfd]\"; \n");
				fwrite($open,"$"."query[$xx] = \"$query[$dfd]\"; \n");
				$xx = $xx+1;
			}			
		}
		fwrite($open,"?>");
		
		echo "<div align=center><font color=green>Deleted the query</font></div>";
	}
	else if($position != "" && $position != null)
	{
		$query[$position] = $querya;
		$name[$position] = $namea;		

		$open = fopen("queries.php","w");
		fwrite($open,"<?php \n\n");
		
		for($dfd=0; $dfd < count($query); $dfd++){
			fwrite($open,"$"."name[$dfd] = \"$name[$dfd]\"; \n");
			fwrite($open,"$"."query[$dfd] = \"$query[$dfd]\"; \n");
		}
		fwrite($open,"?>");
		
		echo "<div align=center><font color=green>Update the query</font></div>";
	}


	for($dfd=0; $dfd < count($query); $dfd++){
		if($dfd%2 == 0)
			$col = "#efefef";
		else
			$col = "#cfefcf";

		if(!($delete == "yes" && $position == $dfd)){

		echo "<tr bgcolor=$col><td align=center><br>
		<form name=xxx method=post style=\"margin: 0px; padding: 0px;\">	
		<input type=hidden name=position value=$dfd></input>";
		$namea = $name[$dfd];
		echo "Display Name: <input name=namea value=\"$namea\"></input><br>";
		$quer = $query[$dfd];
		echo "Query <textarea name=querya cols=44 rows=4>".$quer."</textarea><br><br>";		
		echo "</td><td valign=center>
		<input type=submit value=update></form><br><br>
		<form name=yyy method=post style=\"margin: 0px; padding: 0px;\">	
		<input type=hidden name=position value=$dfd></input>
		<input type=hidden name=delete value=yes></input>
		<input type=submit value=delete>
		</form><br><br></td></tr>";
	
		}
	}
?>
</table>


</td>
</tr>

<tr>
<td  align=center valign=top>
<br>
</td>
</tr>

</table>
</body>
</html>

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