dunque, particamente il mio problema era che avendo due funzioni diverse per le due diverse paginazioni, non riuscivo ad usare valori "comuni" per entrambe...
ho risolto facendo una sola funzione per entrambe le paginazioni, in questo modo:
Codice PHP:
function STAMPA_OPERE_TESTI_ARTISTA($artistaId)
{
require "inc.config.php";
require "inc.connect.php";
// esecuzione prima query OPERE
$query_count_opere = mysql_query("SELECT COUNT(operaId) FROM opere WHERE artistaId = $artistaId");
$res_count_opere = mysql_fetch_row($query_count_opere);
// esecuzione prima query TESTI
$query_count_testi = mysql_query("SELECT COUNT(testoId) FROM testi WHERE artistaId = $artistaId");
$res_count_testi = mysql_fetch_row($query_count_testi);
// numero totale di records
$tot_records_opere = $res_count_opere[0];
$tot_records_testi = $res_count_testi[0];
// risultati per pagina(secondo parametro di LIMIT)
$per_page_opere = 10;
$per_page_testi = 10;
// numero totale di pagine
$tot_pages_opere = ceil($tot_records_opere / $per_page_opere);
$tot_pages_testi = ceil($tot_records_testi/ $per_page_testi);
// pagina corrente
if (!isset($_GET['page_opere']))
$current_page_opere = "1";
else
$current_page_opere = $_GET['page_opere'];
if (!isset($_GET['page_testi']))
$current_page_testi = "1";
else
$current_page_testi = $_GET['page_testi'];
// primo parametro di LIMIT
$primo_opere = ($current_page_opere - 1) * $per_page_opere;
$primo_testi = ($current_page_testi - 1) * $per_page_testi;
// esecuzione seconda query con LIMIT
$query_limit_opere = mysql_query("SELECT * FROM opere WHERE artistaId = $artistaId LIMIT $primo_opere,$per_page_opere");
// visualizzazione dei dati delle opere
echo "<h3>Opere:</h3>";
echo "<table>";
while ($row_opere = mysql_fetch_assoc($query_limit_opere))
{
echo "<tr>";
echo "<td>[b][i]$row_opere[titolo][/i][/b]</td>";
echo "<td>-</td>";
echo "<td>$row_opere[anno]</td>";
echo "<td>,</td>";
echo "<td>$row_opere[tecnica]</td>";
echo "<td>su</td>";
echo "<td>$row_opere[supporto]</td>";
echo "<td>, cm</td>";
echo "<td>$row_opere[altezza] x $row_opere[larghezza]</td>";
echo "<td>-</td>";
echo "<td>[url='scheda_opera.php?id=$row_opere[operaId]']Vedi[/url]<td>";
echo "</tr>";
}
echo "</table>";
if ($tot_pages_opere != 1 && $tot_pages_opere != 0)
{
echo "
";
// creazione della variabile "paginazione"
$paginazione_opere = "Pagine totali: [b]" . $tot_pages_opere . "[/b] [";
for ($i = 1; $i <= $tot_pages_opere; $i++)
{
if ($i == $current_page_opere)
{$paginazione_opere .= $i;}
else {$paginazione_opere .= "[url='?id=$artistaId&page_opere=$i&page_testi=$current_page_testi']$i[/url]";}
}
$paginazione_opere .= "]";
// inserisco la paginazione nella cella
echo "<div align='center'>";
echo "<table>";
echo "<tr>";
echo "<td>$paginazione_opere</td>";
echo "</tr>";
echo "</table>";
echo "</div>";
}
echo "<hr width='75%'>";
// esecuzione seconda query con LIMIT
$query_limit_testi = mysql_query("SELECT * FROM testi WHERE artistaId = $artistaId LIMIT $primo_testi,$per_page_testi");
// visualizzazione dei dati deli testi
echo "<h3>Testi in cui è stato citato:</h3>";
echo "<table>";
while ($row_testi = mysql_fetch_array($query_limit_testi))
{
echo "<tr>";
echo "<td>[i]$row_testi[titoloTesto][/i]</td>";
echo "<td>,</td>";
echo "<td>$row_testi[titoloVolume]</td>";
echo "<td>di</td>";
echo "<td>$row_testi[autoreNome] $row_testi[autoreCognome]</td>";
echo "<td>[url='scheda_testo.php?id=$row_testi[testoId]']Vai![/url]</td>";
echo "</tr>";
}
echo "</table>";
if ($tot_pages_testi != 1 && $tot_pages_testi != 0)
{
echo "
";
// creazione della variabile "paginazione"
$paginazione_testi = "Pagine totali: [b]" . $tot_pages_testi . "[/b] [";
for ($x = 1; $x <= $tot_pages_testi; $x++)
{
if ($x == $current_page_testi)
{$paginazione_testi .= $x;}
else {$paginazione_testi .= "[url='?id=$artistaId&page_testi=$x&page_opere=$current_page_opere']$x[/url]";}
}
$paginazione_testi .= "]";
// inserisco la paginazione nella cella
echo "<div align='center'>";
echo "<table>";
echo "<tr>";
echo "<td>$paginazione_testi</td>";
echo "</tr>";
echo "</table>";
echo "</div>";
}
mysql_free_result($query_limit_testi);
mysql_free_result($query_limit_opere);
mysql_close();
}
Funziona bene, ma non sono sicuro che sia una soluzione stilisticamente e tecnicamente corretta... che ne pensate?