Buon giorno a tutti,
ho il seguente script che applicato ad una mia tabella mi fa una corretta paginazione dei risultati:
codice:
<?php
	session_start();
	session_register('id'); 
	//Array to store validation errors
	$errmsg_arr = array();
	
	//Validation error flag
	$errflag = false;


require "config.php";
require "dbms.inc.php";
require "paginazione.inc.php";

$webpage = basename($_SERVER['PHP_SELF']);
$page = (!isset($_GET['page']))? 1 : $_GET['page'];
$result = mysql_query("select * FROM  utenti ORDER BY id ASC");
$max_results = 10;//numero di elementi da visualizzare per pagina.
$total_results = mysql_num_rows($result);
$total_pages = ceil($total_results / $max_results);
$from = (($page * $max_results) - $max_results);
$result=mysql_query("select * FROM utenti ORDER BY data_reg DESC LIMIT $from, $max_results ");

echo '
<CENTER><table><table border="0" cellpadding="8" cellspacing="5">
<tr>
<td>Data inserimento</td>
<td>Nome</td>
<td>Cognome</td>
<td>Segnalatore</td>
<td>Servizio inviante</td>
<td>Tutor</td>
<td>Stato</td>
<td></td>
<td></td>
</tr>
 
	';
 
while ($i = mysql_fetch_array($result))
{
	echo '
<tr>
<td>' . $i['data_reg'] . '</td>
<td>' . $i['nome'] . '</td>
<td>' . $i['cognome'] . '</td>
<td>' . $i['segnalatore'] . '</td>
<td>' . $i['servinviante'] . '</td>
<td>' . $i['tutor'] . '</td>
';
if ($i['stato']=="Assegnato SIL") {
echo '
<td BGCOLOR="#FF6699">' . $i['stato'] . '</td>
';
}
if ($i['stato']=="Da assegnare") {
echo '
<td BGCOLOR="#00FF00">' . $i['stato'] . '</td>
';
}
echo '
<td>[img]modify.gif[/img]</td>
<td>[img]trashcan.gif[/img]</td>
</tr>
 
		';
}
 
echo '</table></CENTER>
 
';

echo pagination_3($total_pages, $page, $webpage);

?>
Questo codice funziona perfettamente!

Poi ho quest'altro, anch'esso testato, che ordina le colonne cliccando sulle intestazioni delle stesse:

codice:
<?php  

$query2 = "select id,cognome,nome,titolo,sesso from utenti"; 
 $rs2 = mysql_query($query2) or die(mysql_error());  
$num = mysql_num_rows($rs2);  

if ($num == 0)  
    echo "<div style=\"text-align:center\">Nessun contatto presente nel comune</div>"; 
         else  
          {  
             if(empty($_GET['ordercampo']))  
             $_GET['ordercampo'] = "id"; 
          
             if(empty($_GET['order']))  
             $_GET['order'] = "asc"; 
          
             if($_GET['order']=="asc") {$ordinaVerso = "desc";}  
             if($_GET['order']=="desc") {$ordinaVerso = "asc";}  
             $query2 = "select id,cognome,nome,titolo,sesso from utenti order by $_GET[ordercampo] $ordinaVerso ";
              $rs = mysql_query($query2) or die(mysql_error());  
        ?>  
        <table border="1">  
        <tr>  
        <td align="center">Cognome</td> 
         <td align="center">Nome</td> 
         <td align="center">Sesso</td> 
          </tr>  
          <?php  
        while($results = mysql_fetch_array($rs))  
            {  
                echo "<tr>";  
                $id = $results['id'];  
                echo "<td width=\"25%\">$results[cognome]</td>";  
                echo "<td width=\"25%\">$results[nome]</td>";  
                echo "<td width=\"25%\">$results[email]</td>";  
                echo "</tr>";  
            } //fine ciclo while  
        } //fine else nel caso ci sia almeno un contatto nel comune  
?>
Il mio problema è che vorrei fare un merge dei due in modo tale che lo script faccia entrambe le cose. Ci sto provando da due giorni ma non riesco proprio. Ho provato ad uniformare i nomi delle variabili e degli array dei due script di modo da facilitarmi la vita ma non ci riesco ugualmente. Qualcuno ha voglia di darci un'occhiata?

Grazie in anticipo!!

Ciao

TP