All pastes #148131 Raw Edit

Anonymous

public text v1 · immutable
#148131 ·published 2006-08-24 22:11 UTC
rendered paste body
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>







<?php
include('common.php');
connectdb();
echo "Success.... Generating menu.<BR>";

ob_start();


?>

   <table width="222" height="68" border="1" cellpadding="3" bordercolor="#AA0000" style="border-collapse: collapse">
  <tr>
    <td height="24" bgcolor="#AA0000" bordercolor="#AA0000"><div align="center" class="style12">
      <span class="Header">
		<font color="#FFFFFF" face="Trebuchet MS" style="font-size: 9pt">Produktkategorier</font></span></div></td>
</tr>
  <tr>
    <td bgcolor="#FFFFFF" bordercolor="#FFFFFF">
      <BR />
	  
<?php

//Get the categories its a part of for opening purposes
if ($_GET['cat'] != "") {
$curcat = $_GET['cat'];
	do {
		$categories[] = $curcat;
		$sql = "select supercat from categories where id = ".$curcat;
		$query = mysql_query($sql);
		$row = mysql_fetch_array($query);
		$curcat = $row['supercat'];
		
	} while ($curcat != "-1" );
	
}

	$sql = "select * from categories where supercat = '-1' order by catname ASC";
	$query = mysql_query($sql) or die(mysql_error("here".$sql));
	$numrows = mysql_num_rows($query);
	echo "numrows".$numrows;

	$counter = 0;
	while ($row = mysql_fetch_array($query, MYSQL_BOTH) && $counter < 10) {
	echo $row[0];
	$myticker = 0;
	echo $counter;
	$counter++;
	echo ".";
	print_r($row);
	echo ".";
	echo ("id is ".$row[0]);
	
		$sql = "select * from categories where supercat = ".$row['id']." order by catname ASC";
	$query2 = mysql_query($sql) or die(mysql_error().$sql);
	if (mysql_num_rows($query2) >= 1) {
	?>
<a href="javascript:switchit('b<?php echo $row['id']; ?>')" id = "ab<?php echo $row['id']; ?>" class="maincats"><?php echo $row['catname']; ob_flush(); ?></a><BR />


	<ul id="b<?php echo $row['id']; ?>" style="<?php if (checkcat($categories, $row['id'])) { ?>display:block;<?php } else { ?> display:none;<?php } ?>">
	
	<?php
	} else {
		//Get num of products
		$newsql = "select * from products where product_cat = ".$row['id'];
		$newquery = mysql_query($newsql) or die(mysql_error());
		$numproducts = mysql_num_rows($newquery);
	?>
	<a class="maincats_minus" href="cart.php?cat=<?php echo $row['id']."&"."session=<?php echo session_id(); ?>"."\">".$row['catname']."</a> <span class = number>(".$numproducts.")</span>"; ?><BR />
	<ul id="b<?php echo $row['id']; ?>" style="display:none;">
	<?php
	
	
	
	}

	
	while ($row2 = mysql_fetch_array($query2)) { 
	
			$sql = "select * from categories where supercat = ".$row2['id']." order by catname ASC";
	$query3 = mysql_query($sql) or die(mysql_error());
		if (mysql_num_rows($query3) >= 1) {
		$myticker = $myticker + 1;
	?>
      <li class="menu"><b><a href="javascript:switchit('b<?php echo $row2['id']; ?>')" class="highercats" id = "ab<?php echo $row2['id']; ?>"><?php echo $row2['catname']; ?></a></b></li>
<ul style="<?php if (checkcat($categories, $row2['id'])) { ?>display:block;<?php } else { ?> display:none;<?php } ?>" id = "b<?php echo $row2['id']; ?>"><?php
	} else {
		//Get num of products
		$newsql = "select * from products where product_cat = ".$row2['id'];
		$newquery = mysql_query($newsql) or die(mysql_error());
		$numproducts = mysql_num_rows($newquery);
	?>
	<li id = <?php echo $row2['id']; ?> class = "menu"><a class="lowercats" href="cart.php?cat=<?php echo $row2['id']."&"."session=<?php echo session_id(); ?>"."\">".$row2['catname']."</a> <span class = number>(".$numproducts.")"; ?></span></li>
	<?php
	}
	
	while ($row3 = mysql_fetch_array($query3)) { 
	
	
			//Get num of products
		$newsql = "select * from products where product_cat = ".$row3['id'];
		$newquery = mysql_query($newsql) or die(mysql_error());
		$numproducts = mysql_num_rows($newquery);
	
	?><li class="menu"><a class="lowercats" href="cart.php?cat=<?php echo $row3['id']."&"."session=<?php echo session_id(); ?>"."\">".$row3['catname']."</a> <span class = number>(".$numproducts.")</span>"; ?></li>
	<?php
	}
	if (mysql_num_rows($query3) > 0) {
	?>
	</ul>
	<?php
	}
		if (mysql_num_rows($query2) >= $myticker) {
	?>
	
	<?php
	} else {
	}
	}
echo "</ul>";
}
	?>  <BR /></td>
    
  
    
  </tr>
  </table>

  <?php //Get the categories its a part of for opening purposes
if ($_GET['cat']!= "") {

	//Now set all opened cats icon to -
	for ($i = 1; $i < count($categories); $i++) { 
		echo "<script>makeminus('".$categories[$i]."');</script>";
	}
}

?>
  <font face="Trebuchet MS" size="1"><br>
	</font><div align = center><font face="Trebuchet MS" style="font-size: 9pt" align=>Alla priser inkl 
	moms</font></div></div>
	
	<?php
	$var = ob_get_contents();
	error_reporting(E_ALL);

	$fp = fopen("menu.php","w");
	fwrite($fp, $var);
	?>
</body>
</html>