PHP gevorderde |
|
Als ik mijn script uitvoer in de browser word het eerste gegeven uit mijn database ontzettend veel weergeven en dan krijg ik de error:
Fatal error: Maximum execution time of 30 seconds exceeded in c:\apache\htdocs\ps\gastenboek.php on line 15
Wat is verkeerd in de code?
<?
$page = (!isset($_GET['page'])) ? 1 : $_GET['page'];
//aantal records per pagina
$max = 20;
$start = ($max * $page) - $max;
//hier je gegevens van je mysql ophalen
while($var = mysql_fetch_array(mysql_query("SELECT * FROM gastenboek ORDER BY ID LIMIT " . $start . ", " . $max . ""))) {
?>
<table width="75%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr bgcolor="#E6E6E6">
<td width="11%" class="Left_Top">Naam:</td>
<td width="61%" class="Top"><a href="mailto:<? print $var['email']; ?>?subject=Re:%20Gastenboek%20-%20Zwobbel"><strong><? print $var['naam']; ?></strong></a></td>
<td width="28%" class="Right_Top"><div align="right" class="Datum"><? print $var['datum']; ?></div></td>
</tr>
<tr bgcolor="#E6E6E6">
<td class="Left">Website:</td>
<td colspan="2" class="Right"><a href="<? print $var['website']; ?>" target="_blank"><? print $var['website']; ?></a></td>
</tr>
<tr>
<td colspan="3" class="Kader"><? print $var['bericht']; ?></td>
</tr>
</table>
<?
}
//hier aan jou mysql gegevens aanpassen
$rows = mysql_result(mysql_query("SELECT COUNT(id) FROM gastenboek ORDER BY ID"),0);
$pages = ceil($rows / $max);
if ($page > 1) {
$previous = $page - 1;
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?a=".$_GET['a']."&page=" . $previous . "\">Vorige</a> ";
}
for ($i = 1; $i <= $pages; $i++) {
if ($page == $i) {
if ($i == $pages) {
echo "<b>" . $i . "</b> ";
} else {
echo "<b>" . $i . "</b>, ";
}
} else {
if ($i == $pages) {
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?a=".$_GET['a']."&page=" . $i . "\">" . $i . "</a> ";
} else {
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?a=".$_GET['a']."&page=" . $i . "\">" . $i . "</a>, ";
}
}
}
if ($page < $pages) {
$next = $page + 1;
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?a=".$_GET['a']."&page=" . $next . "\">Volgende</a>";
}
?>
<? $page = (!isset($_GET['page'])) ? 1 : $_GET['page']; //aantal records per pagina $max = 20; $start = ($max * $page) - $max; //hier je gegevens van je mysql ophalen ?> <table width="75%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr bgcolor="#E6E6E6"> <td width="11%" class="Left_Top">Naam:</td> <td width="61%" class="Top"><a href="mailto: <? print $var['email']; ?>?subject=Re:%20Gastenboek%20-%20Zwobbel"><strong> <? print $var['naam']; ?></strong></a></td> <td width="28%" class="Right_Top"><div align="right" class="Datum"> <? print $var['datum']; ?></div></td> </tr> <tr bgcolor="#E6E6E6"> <td class="Left">Website:</td> <td colspan="2" class="Right"><a href=" <? print $var['website']; ?>" target="_blank"> <? print $var['website']; ?></a></td> </tr> <tr> <td colspan="3" class="Kader"> <? print $var['bericht']; ?></td> </tr> </table> <? } //hier aan jou mysql gegevens aanpassen $pages = ceil($rows / $max); if ($page > 1) { $previous = $page - 1; echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?a=".$_GET['a']."&page=" . $previous . "\">Vorige</a> "; } for ($i = 1; $i <= $pages; $i++) { if ($page == $i) { if ($i == $pages) { echo "<b>" . $i . "</b> "; } else { echo "<b>" . $i . "</b>, "; } } else { if ($i == $pages) { echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?a=".$_GET['a']."&page=" . $i . "\">" . $i . "</a> "; } else { echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?a=".$_GET['a']."&page=" . $i . "\">" . $i . "</a>, "; } } } if ($page < $pages) { $next = $page + 1; echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?a=".$_GET['a']."&page=" . $next . "\">Volgende</a>"; } ?>
EDIT:
Ik heb even verder zitte zoeken achter een beter script en heb er nu een werkend gevonden.
TOch bedankt
|