Copio il codice :
Codice PHP:
<?php
session_start();
//includo i comandi principali
include "connessione.php";
include "controllo_sessione.php";
include "functions/db.php";
//prendo il CSS
$page="<link rel=stylesheet href=\"default.css\" type=\"text/css\">";
//includo la jquery box per i-frame
$page.="<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
<script type=\"text/javascript\" src=\"js/script.js\"></script>
<script type=\"text/javascript\" src=\"js/jquery-1.4.2.min.js\"></script>
<script type=\"text/javascript\" src=\"fancybox/jquery.fancybox-1.3.1.pack.js\"></script>
<script type=\"text/javascript\" src=\"fancybox/jquery.easing-1.3.pack.js\"></script>
<link rel=\"stylesheet\" href=\"fancybox/jquery.fancybox-1.3.1.css\" type=\"text/css\" media=\"screen\" />
<script type=\"text/javascript\">
jQuery(document).ready(function() {
jQuery(\".more\").fancybox({
'height' : '90%',
'width' : '90%',
'transitionIn' : 'none',
'transitionOut' : 'none',
'type' : 'iframe'
});
});
</script>";
$liv_accesso = $_SESSION['level'];
//controllo i dati nel get e nel post
//inizio con il controllare se vuoi vedere una pagina diversa dalla prima nei risultati.
if (empty($_GET['limit'])) {
$limit = 0;
} else {
$limit = $_GET['limit'] * 50;
}
$limit2= 50;
//controllo se hai un ordine di preferenza di display delle pratiche
if ((empty ($_GET['order'])) && (empty($_POST['order'])))
{$order = "ID";}
elseif (empty($_POST['order']))
{$order = $_GET['order'];}
else {$order = $_POST['order'];}
$user = $_SESSION['user'];
//creo la query frammentata
$query = "QUERY SELECT * FROM commerciale_nominativi WHERE";
if (!empty($_POST['inizio'])){
$query.=" ID>='".$_POST['inizio']."' AND ID<='".$_POST['fine']."'";
}else {
$query.=" YANK='$user'";
}
if (!empty($order)){
$query.=" ORDER BY $order ASC";
}
$sql_user = query("$query");
//se sei l'admin, ti metto i riquadri
if ($_SESSION['level']==5) {
$page.="<center><form name=\"0\" action=\"commerciale.php\" method=\"post\">
Seleziona un gruppo di nominativi
<table border=\"0\"><tr><th>
<font face =\"verdana\" size=\"2\">[/B]Dal nominativo numero </font></th><th><input type=\"text\" name=\"inizio\"> </tr><tr><th><font face =\"verdana\" size=\"2\">[/B]al nominativo numero</font> </th><th><input type=\"text\" name=\"fine\"></th></tr>
</table><input type=\"submit\" value=\" Vai \"></form></center></TD>
</center></tr></table>
";
}
$page.= "<form action=\"assegna_comm.php\" method=\"post\">
<table id=\"table20\" width=\"95%\" align=\"center\" cellpadding=\"3\">
<tbody>
<tr>
<th class=\"tabella\"><font size=\"1\">N.</font></th>
<th class=\"tabella\"><font size=\"1\">Denominazione</font></th>
<th class=\"tabella\"><font size=\"1\">Stato</font></th>
<th class=\"tabella\"><font size=\"1\">Città</font></th>";
if ($_SESSION['level']== 5) {
$page.="<th class=\"tabella\">Selezione</th>";
}
$page.="<tr>";
$selez =array();
while ($case = query("FETCH", $sql_user))
{
$page.="<tr>
<th class=\"tabellina\"><a class=\"more\" href=\"scheda_comm.php?id=".$case['ID']."\"><font color=\"Black\">".$case['ID']."</font></th>
<th class=\"tabellina\">".$case['nome']."</th>
<th class=\"tabellina\">".$case['stato_chiamata']."</th>
<th class=\"tabellina\">".$case['citta']."</th>";
if ($_SESSION['level']== 5) {
$page.="<th class=\"tabellina\"><input name=\"selez[]\" type=\"checkbox\" value=\"".$case['ID']."\" checked=\"checked\"></th>";
}
$a = $case['ID'];
array_push($selez, "$a");
$page.="</tr>";
}
$page.="</table>";
if ($_SESSION['level']== 5) {
$liv=4;
$sql = mysql_query("SELECT * FROM users where Livello = '$liv' ORDER BY User ASC")or die(mysql_error());
$page.= "<center><select name=\"who\">";
while ($opz = mysql_fetch_assoc($sql)){
$page.="<option value=\"".$opz['User']."\">".$opz['User']."</option>";
}
$page.="</select>
<center><input type=\"submit\" value=\"Assegna le pratiche\" ></form> </center>";}
echo $page;
Per qualche arcano motivo, dentro page viene creata la pagina, poi, viene ristampata da capo una seconda volta.
Specifico che viene stampata una seconda volta anche l'intestazione della tabella, non solamente i dati.
Nel codice sopra non ho ancora messo l'opzione per il limit (sebbe ci sia la struttura) volevo prima risolvere questo problema.