Re: Only showing 20 lines per page...
Mike wrote:
With a simple calculation of records per page, total records &
requested pagenumber you'll only have to retrieve the relative
resultset from the database, which will mean less resource use with
both database & PHP. Your mentioning of 'storing the results to an
array and looping through that way' get's me a bit confused. It'd be
a waste to turn it into an array, and then proceed. Why not
mysql_fetch_array() the rows and perform your desired actions
immediately?
I thought mysql_fetch_array() did store the results in an array?
Mike
Yes and no, it stores 1 row in an array, not the entire resultset, which is
what got me confused.
When a result is:
+---------+-------+
| article | price |
+---------+-------+
| 0001 | 3.99 |
| 0002 | 10.99 |
| 0003 | 1.69 |
| 0004 | 19.95 |
+---------+-------+
mysql_fetch_array() will contain the first row (and move the pointer to the
second):
array {
[article] => 0001,
[price] => 3.99
}
Grtz,
--
Rik Wasmus
.
Relevant Pages
- Re: Quick Question on Sessions
... Here is checkUserSession() function: ... you should never use SELECT * in your database queries. ... echo and array are two completely different things. ... (comp.lang.php) - Re: [PHP] Creating single row for multiple items.
... there's nothing wrong with storing an order number in a database with all the item numbers that are associated/ordered with that order. ... element) and set the price if the array element is just being set (use ... [PHP] Creating single row for multiple items. ... what you are attempting to do is what MySQL works best at -- namely pull all all the records that have the same order number. ... (php.general) - Re: list box with items for deletion passed from php array
... I want to display a list box that contains the elements from an array ... (queried from database). ... It seems to me the functions for populating ... // $options is the php array queried from database ... (comp.lang.javascript) - Re: [PHP] Speed Opinion
... Is if faster to just read all the records from both tables into two arrays, then use php to go through the array for table 1 and figure out what records from table 2 are related. ... Or, you dump all the data in table 1 into an array, then as you go through each record you make a database query to table 2. ... I know I can use a join, but I find anytime I use a join, the database query is extremely slow, I have tried it for each version of mysql and php for the last few years. ... (php.general) - Re: [PHP] Speed Opinion
... Is if faster to just read all the records from both tables into two arrays, then use php to go through the array for table 1 and figure out what records from table 2 are related. ... Or, you dump all the data in table 1 into an array, then as you go through each record you make a database query to table 2. ... I know I can use a join, but I find anytime I use a join, the database query is extremely slow, I have tried it for each version of mysql and php for the last few years. ... (php.general) |
|