Re: Only showing 20 lines per page...
- From: "Rik" <luiheidsgoeroe@xxxxxxxxxxx>
- Date: Sun, 16 Jul 2006 20:47:00 +0200
Mike wrote:
OK, think I have got it...
I can do the count using select count(id) and the maths to work out
the start and finish.
This is how I think using mysql_fetch_array works...
$conn = //db connection stuff
$sql = "select VALUES from TABLE LIMIT X,X";
$sql1 = "mysql_query($sql,$conn) or die(mysql_error());
while ($results = mysql_fetch_array($sql1)) {
$value1 = $results['value1'];
$value2 = $results['value2'];
.
.
.etc..
//create a display block
echo $value1
echo $value2
.
.
.etc..
}
More or less, but why assigning intermediate variables?
Lets for instance say I have a db with an image url & an alt-text
while ($results = mysql_fetch_array($sql1)) {
echo "<img src=\"{$results['url']}\" alt=\"{$results['alt']}\" />";
}
I think I was confused as I'm used to seeing a counter var incremented
as the check to see when to dump out of the while loop. I couldn't
see how it knew to move to the next row each time. Can you explain?
From the manual:Returns an array that corresponds to the fetched row and moves the internal
data pointer ahead.
So, by setting the pointer forward, the next row will be returned the next
time the function is called. Because it returns false if there are no more
rows it the while loop will stop after the last row.
Grtz,
--
Rik Wasmus
.
- Follow-Ups:
- Re: Only showing 20 lines per page...
- From: Mike
- Re: Only showing 20 lines per page...
- References:
- Only showing 20 lines per page...
- From: Mike
- Re: Only showing 20 lines per page...
- From: Rik
- Re: Only showing 20 lines per page...
- From: Mike
- Re: Only showing 20 lines per page...
- From: Mike
- Only showing 20 lines per page...
- Prev by Date: Re: Only showing 20 lines per page...
- Next by Date: Re: Only showing 20 lines per page...
- Previous by thread: Re: Only showing 20 lines per page...
- Next by thread: Re: Only showing 20 lines per page...
- Index(es):
Relevant Pages
|