<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Web management</title>
<link rel="stylesheet" href="styles.css" type="text/css">
<?php include 'codes.php';?>
</head>
<body text="#000000" style="margin:0">
<?php
$id = mysql_real_escape_string(stripslashes($_REQUEST['id']));
	 	$result = mysql_query("SELECT * FROM infocategories WHERE id='$id'",$dbh);
			$myrow=mysql_fetch_array($result); 
			$category=$myrow['category'];
?>

  <?php
if  (isset($_POST['submit'])) {
$sql="DELETE FROM infocategories WHERE id='$id'";
	$result=mysql_query($sql);	
	
	$sql11="DELETE FROM infocategories WHERE parent='$id'";
	$result11=mysql_query($sql11);
	
    $sql12="DELETE FROM info WHERE category_id='$id'";
	$result12=mysql_query($sql12);

?>
<meta http-equiv="refresh" content="0;URL=all-infocategories.php">
<?php
} else {	
	
?>
<?php
			$sql1 = "SELECT * FROM info WHERE category_id='$id'";
			$result1 = mysql_query($sql1);
			$nu_row1 = mysql_num_rows($result1);
?>
<?php
			$sql2 = "SELECT * FROM infocategories WHERE parent='$id'";
			$result2 = mysql_query($sql2);
			$nu_row2 = mysql_num_rows($result2);
?>
<?php
$allrows=$nu_row1 + $nu_row2;
      ?>

<table width="980" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><div><img src="img/frame-delete.png" width="180" height="37" alt=""></div>
<div class="frame">

<form name="forma" method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" enctype="multipart/form-data">
  <table width="100%" border="0" cellspacing="0" cellpadding="4" class="text">
    <tr>
      <td><input type="hidden" name="id" value="<?php echo $id ?>">
     <?php if ($allrows!='0') { ?>
      Υπάρχουν <b> 
  <?php echo $allrows ?>
  </b> καταχωρήσεις στην κατηγορία <b><?php echo $category ?></b>. <br>
  Αν πατήσετε Διαγραφή θα διαγραφούν όλες οι υποκατηγορίες 
  και οι καταχωρήσεις που ανήκουν σε αυτή.
  <?php } ?>
      </td>
      </tr>
    </table>

  <div align="center" style="padding:5px">
   <input type="submit" name="submit" value="Διαγραφή" class="button"></div>
</form>  
</div></td>
  </tr>
</table><?php include 'menudown.php';?>
<?php } ?>
</body>
</html>
