<?php
$id = $rij['ID'];
$titel = $rij['titel'];
$datum = $rij['datum'];
$bericht = $rij['bericht'];
?>
Dit stukje is natuurlijk redelijk zinloos, zo kun je nog wel een stuk of tig variabelen gaan aanmaken met dezelfde inhoud. Niet doen dus, het vreet alleen maar extra geheugen en kost dus onnodig extra tijd.
En wanneer jij de 1e 2 resultaten niet wilt hebben, waarom vraag je ze dan op? Met een LIMIT kun je precies aangeven wat je hebben wilt. Duik eens in de MySQL-handleiding en probeer eens wat.
Ik denk dat je dan het beste gewoon kan tellen:
<?
$i=1;
while($rij = mysql_fetch_array($resultaat))
{
if($i >= 3){
$id = $rij['ID'];
$titel = $rij['titel'];
$datum = $rij['datum'];
$bericht = $rij['bericht'];
}
$i++;
}
?>
@frank
The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement. LIMIT takes one or two numeric arguments, which must both be non-negative integer constants (except when using prepared statements).
With two arguments, the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1):
SELECT * FROM tbl LIMIT 5,10; # Retrieve rows 6-15