sto seguendo la Guida pratica Php/MySql
che si trova su
http://freephp.html.it/guide/index.asp
il problema e' che o e' sbagliato quello che e' scritto o c'e'
qualcosa che non ho capito io.....(sicuramente quest'ultima)
ora copio e incollo la pagina all.php
scritta da me , seguendo la guida (diciamo che e' coppiata paro paro)
<?php
include("top_foot.inc.php") ;
include("config.inc.php") ;
top() ;
$db = mysql_connect($db_host, $db_user, $db_password);
if ($db == FALSE)
die ("Errore nella connessione. Verificare i parametri nel file config.inc.php");
mysql_select_db($db_name, $db)
or die ("Errore nella selezione del database. Verificare i parametri nel file config.inc.php");
if (!IsSet($start) OR $start < 5)
$start = 0 ;
$step = 5 ;
$query = " SELECT id,data,titolo FROM news ORDER BY data DESC LIMIT $start,$step" ;
$result = mysql_query($query,$db);
while ($row = mysql_fetch_array($result))
{echo "<a href=\"view.php?id=$row[id]\">".date("y/n/y", $row[data])."- $row[titolo]</a>
";}
?>
<table width="90%" border="1">
<tr>
<td width="20%" align="left"><?PHP
if ($start > 0) {
$start_back = $start - $step ;
echo "<a href=\"all.php?start=$start_back\">precedenti</a>";}
?></td>
<?php
$query = "SELECT COUNT(*) AS tot FROM news" ;
$result = mysql_query($query,$db);
$row = mysql_fetch_array($result);
$page = intval($row[tot]-1) / $step +1 ;
?>
<td width="60%" align="left">
<?php
for ($i = 0 ; $i < $page AND $i < 20 ; $i++) {
$start_page = $i * $step ;
echo "<a href=\"all.php?start=$start_page\">".($i +1)."</a>";
$start = $start + $step ; #aggiunta da me...ma non funzia
}
?></td>
<td width="20" align="center"><?php
if ($start + $step < $row[tot]) {
$start_next = $start + $step ;
echo "<a href=\"all.php?start=$start_next\">successivo</a>" ;
}
?>
</td>
</tr>
</table>
<?php
echo"<a href=\"search.php\">cerca negli articoli</a>";
foot()
?>
ora funziona tutto tranne il fatto
che la variabile
$start non viene incrementata,
e che quindi in ogni pagina visualizza sempre i soliti 5 articoli
rileggendo il codice, non trovo niente che faccia incrementare
o diminuire la variabile(o non lo vedo io)
ho provato a inserire , giusto x prova
$start = $start + $step ;
nel ciclo for (anche se immaginavo non servisse a nulla
qualche consiglio???
grazie![]()