<form id="form2" name="form2" method="post" action="i-prodotti.php">
  <p align="left">
    <?php
//echo"<hr /><br>";
	 
$cat=$_GET['cat'];
$id_prodotto=$_GET['id_prodotto'];
//TROVO IL NOME DELLA CATEGORIA
	  	  	  $query = "SELECT * FROM ...    ";
			  //echo $query;
              $result = mysql_query($query) or die(mysql_error());
              $numrows = mysql_num_rows($result);
			  $resrow = mysql_fetch_array($result);
			  $nome_cate=$resrow['nome'];
			  
echo"Stai visualizzando la categoria $nome_cate"."<br><br>";			  
    $pag = $_GET["pag"];
    if (isset($pag) == false || is_numeric($pag) == false || $pag < 1)
    {
        $pag = 1;
    }
    $fine = 6;
    $inizio = ($pag - 1) * $fine;
		 
			 
    $sql = "SELECT * FROM ... LIMIT " . $inizio . ", " . $fine;
    $query = mysql_query($sql, $cn); 
	
	// TABELLA SINGOLA GENERALE GRANDE
?>
<table align="center"  border="0" cellpadding="7" cellspacing="0" bordercolor="#000000"><tr>
<?php
            $lista = mysql_num_rows($query);  
            $index = 0; 
             
            for ($a = 0; $a < $lista; $a++)  
            {  
                $resrow = mysql_fetch_array($query);  
				
$cliente=$resrow['cliente'];
$ragione_sociale=$resrow['ragione_sociale'];
$uploadfile=$resrow['foto_1'];
$titolo=$resrow['titolo'];
$prezzo_up=$resrow['prezzo_up'];
$prezzo=$resrow['prezzo'];
$fine=$resrow['fine'];
//SCOMPONGO LA DATA E L'ORA PER IL CONTEGGIO DEL TIMER togliendo '1' al mese perchè il mese in conteggio parte da zero.
$anno = substr($fine, 0, 4);   
$mese = substr($fine, 5, 2)-1;  
$giorno = substr($fine, 8, 2);  
//echo $anno."<br>";
//echo $mese."<br>";
//echo $giorno."<br>";
$index++; 
 
?>
         <!-- TIMER DATE -->
                 
<script type="text/javascript">
dateFuture1 = new Date(<?php echo "$anno,$mese,$giorno,00,00,00";?>);
function GetCount(ddate,iid){
	dateNow = new Date();	//grab current date
	amount = ddate.getTime() - dateNow.getTime();	//calc milliseconds between dates
	delete dateNow;
	// if time is already past
	if(amount < 0){
		document.getElementById(iid).innerHTML="SCADUTO !";
	}
	// else date is still good
	else{
		weeks=0;days=0;hours=0;mins=0;secs=0;out="";
		amount = Math.floor(amount/1000);//kill the "milliseconds" so just secs
		weeks=Math.floor(amount/604800);//weeks
		amount=amount%604800;
		days=Math.floor(amount/86400);//days
		amount=amount%86400;
		hours=Math.floor(amount/3600);//hours
		amount=amount%3600;
		mins=Math.floor(amount/60);//minutes
		amount=amount%60;
		secs=Math.floor(amount);//seconds
		if(weeks != 0){out += weeks +" "+((weeks==1)?"settimana":"settimane")+", ";}
		if(days != 0){out += days +" "+((days==1)?"giorno":"giorni")+", ";}
		if(hours != 0){out += hours +" "+((hours==1)?"ora":"ore")+", ";}
		out += mins +" "+((mins==1)?"minuto":"minuti")+", ";
		out += secs +" "+((secs==1)?"secondo":"secondi")+", ";
		out = out.substr(0,out.length-2);
		document.getElementById(iid).innerHTML=out;
		setTimeout(function(){GetCount(ddate,iid)}, 1000);
	}
}
window.onload=function(){
	GetCount(dateFuture1, 'countbox1');
	//you can add additional countdowns here (just make sure you create dateFuture2 and countbox2 etc for each)
};
</script>
</span></span><script type="text/javascript">
var stile = "top=10, left=120, width=1000, height=800, status=no, menubar=no, toolbar=no scrollbars=yes";
function Popup(apri)
{
window.open(apri, "", stile);
}
  </script>
 
<!-- tabella primaria attorno al rettagolo -->
<td><table border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff" >
<!--TABELLA SINGOLO ESTERNO PRIMARIO -->				
<td width="437" height="399" align="center" valign="top"><p><img src="upload_foto/immagini/<?php echo"$uploadfile"; ?>" alt="" width="428" height="318" class="Stile_tabella" align="center" border="5" bordercolor="#FFFFFF"  cellpadding="0" cellspacing=""></p>
    <table width="437" height="168" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="10" height="21" > </td>
        <td colspan="4" ><span class="Titolo_tabella"><?php echo $titolo; ?></span></td>
        <td width="11" > </td>
      </tr>
      <tr>
        <td height="21" > </td>
        <td width="131" height="21" > </td>
        <td width="107" height="21" > </td>
        <td width="14" height="21" > </td>
        <td width="165" height="21" > </td>
        <td width="11" height="21" > </td>
      </tr>
      <tr>
        <td width="10" height="21" > </td>
        <td height="21" > </td>
        <td height="21" > </td>
        <td rowspan="2" bgcolor="#0066CC" class="Prezzo_tabella"> </td>
        <td rowspan="2" bgcolor="#0066CC" class="Prezzo_tabella"><?php echo "€ ".$prezzo; ?></td>
        <td height="21" > </td>
      </tr>
      <tr>
        <td height="21" > </td>
        <td height="21" > </td>
        <td height="21" > </td>
        <td height="21" > </td>
      </tr>
      <tr>
        <td height="21" > </td>
        <td height="0" ><span class="Timer_tabella"></span>
          
        </td>
        <td height="0" > </td>
        <td height="21" > </td>
        <td height="21" > </td>
        <td height="21" > </td>
      </tr>
      <tr>
        <td height="21" > </td>
        <td height="21" colspan="2" > </td>
        <td height="21" > </td>
        <td height="21" > </td>
        <td height="21" > </td>
      </tr>
      <tr>
        <td height="21" > </td>
        <td height="21" colspan="4" bgcolor="#FF0000" >
        
        
        <div class="Timer_tabella" align="center" id="countbox1"></div>
        
        
        
       
        
        
        
        
        
        </td>
        <td height="21" > </td>
      </tr>
      <tr>
        <td height="21" > </td>
        <td height="21" colspan="4" >
          
          </td>
        <td height="21" > </td>
      </tr>
    </table></td></table>
  </td>
  </p>
  <?php
        if($index == 2){ 
        echo"</tr><tr>"; $index = 0;
        } 
            } 
echo "</tr></table>"; 
        mysql_close(); 
 
?>
  <p align="center"> </p>
  <div align="left"><span>
    <?php
 $query = mysql_query("SELECT * FROM ... ", $cn);
    $quanti = mysql_num_rows($query);
    @$intero = $quanti / $fine;
?>
    </span>  </div>
  <p align="left" >
<?php
 for($x=1; $x<$intero+1; $x++)
    {
        if ($x == $pag)
        {
?>
<b><? echo $x;?></b> |
<?
        }
        else
        {
?>
<a href="visit_1_bis.php?pag=<?echo $x;?>&cat=<?echo $cat;?>"><?echo $x;?></a> |
<?
        }
    }
echo"<br>";
if($lista==0){ echo "Nessun prodotto inserito in questa categoria";}
?>
  <?php
    mysql_close($cn);
?>
</form>