Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #15219

Re: fetching all items at once - how do you code to display them?

From Denis McMahon <denismfmcmahon@gmail.com>
Newsgroups comp.lang.php
Subject Re: fetching all items at once - how do you code to display them?
Date 2015-04-06 07:48 +0000
Organization A noiseless patient Spider
Message-ID <mftdpa$t03$3@dont-email.me> (permalink)
References <46bui2hdar3f$.1qryyy3zcx5um.dlg@40tude.net> <mfps3p$j9e$1@dont-email.me> <1lpvv6118algy.1pzxv594x426f$.dlg@40tude.net> <XnsA472D868748A8dougmilmaccom@213.239.209.88> <1at1d2mgi02g2$.1ptb1cxropkt8$.dlg@40tude.net>

Show all headers | View raw


On Sun, 05 Apr 2015 10:56:15 -0400, richard wrote:

> On Sun, 5 Apr 2015 01:15:55 +0000 (UTC), Doug Miller wrote:
> 
>> richard <noreply@example.com> wrote in
>> news:1lpvv6118algy.1pzxv594x426f$.dlg@
>> 40tude.net:
>> 
>> [...]
>>> 
>>> Done that.
>>> What I get is 11 duplicates of the first item.
>>> So why does it stop at 11 when I have 200 records?
>>> 
>> Kind of hard to answer that question when we can't see your code....
> 
> $result = mysqli_query($link,"SELECT * from sixty where (
>   (peak='1')
> 	and (year>1959)
> 	and (year<1970)
>   ) ORDER BY year, sid ");

> $rows = mysqli_fetch_assoc($result);

This thing that you're calling $rows is only getting a single record from 
$result.
 
> $total=count($rows);
> echo $total;  // displays "11"

That's the number of fields in the record you just pulled out of $result, 
not the number of records retrieved.

All the other records are still in $result. This is why you loop through 
$result as I posted earlier.

> echo "<br>";
> echo $rows['title'];  //displays nothing.

That means you don't have a field called 'title' in your record.

try replacing:

> $total=count($rows);
> echo $total;  // displays "11"
> echo "<br>";
> echo $rows['title'];  //displays nothing.

with:

echo '<pre>\n';
echo print_r($rows, true);
echo '</pre>\n';

This will print out the array that corresponds to the record you got from 
$result.

p.s. we're still waiting to hear what the data type of the years field is.

-- 
Denis McMahon, denismfmcmahon@gmail.com

Back to comp.lang.php | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

fetching all items at once - how do you code to display them? richard <noreply@example.com> - 2015-04-03 21:54 -0400
  Re: fetching all items at once - how do you code to display them? Jerry Stuckle <jstucklex@attglobal.net> - 2015-04-03 22:14 -0400
  Re: fetching all items at once - how do you code to display them? Denis McMahon <denismfmcmahon@gmail.com> - 2015-04-04 23:28 +0000
    Re: fetching all items at once - how do you code to display them? richard <noreply@example.com> - 2015-04-04 19:32 -0400
      Re: fetching all items at once - how do you code to display them? Doug Miller <doug_at_milmac_dot_com@example.com> - 2015-04-05 01:15 +0000
        Re: fetching all items at once - how do you code to display them? richard <noreply@example.com> - 2015-04-05 10:56 -0400
          Re: fetching all items at once - how do you code to display them? Richard Yates <richard@yatesguitar.com> - 2015-04-05 08:14 -0700
            Re: fetching all items at once - how do you code to display them? richard <noreply@example.com> - 2015-04-05 11:24 -0400
          Re: fetching all items at once - how do you code to display them? Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2015-04-05 11:18 -0400
            Re: fetching all items at once - how do you code to display them? richard <noreply@example.com> - 2015-04-05 11:28 -0400
              Re: fetching all items at once - how do you code to display them? Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2015-04-05 11:52 -0400
                Re: fetching all items at once - how do you code to display them? Doug Miller <doug_at_milmac_dot_com@example.com> - 2015-04-06 02:01 +0000
                Re: fetching all items at once - how do you code to display them? Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2015-04-08 20:16 -0400
                Re: fetching all items at once - how do you code to display them? richard <noreply@example.com> - 2015-04-09 22:32 -0400
                Re: fetching all items at once - how do you code to display them? Richard Heathfield <rjh@cpax.org.uk> - 2015-04-10 07:48 +0100
                Re: fetching all items at once - how do you code to display them? Doug Miller <doug_at_milmac_dot_com@example.com> - 2015-04-11 03:11 +0000
            Re: fetching all items at once - how do you code to display them? Denis McMahon <denismfmcmahon@gmail.com> - 2015-04-06 07:58 +0000
          Re: fetching all items at once - how do you code to display them? Denis McMahon <denismfmcmahon@gmail.com> - 2015-04-06 07:48 +0000
      Re: fetching all items at once - how do you code to display them? Denis McMahon <denismfmcmahon@gmail.com> - 2015-04-05 04:47 +0000
        Re: fetching all items at once - how do you code to display them? richard <noreply@example.com> - 2015-04-05 10:58 -0400
          Re: fetching all items at once - how do you code to display them? Jerry Stuckle <jstucklex@attglobal.net> - 2015-04-05 11:21 -0400
            Re: fetching all items at once - how do you code to display them? richard <noreply@example.com> - 2015-04-05 11:40 -0400
              Re: fetching all items at once - how do you code to display them? Jerry Stuckle <jstucklex@attglobal.net> - 2015-04-05 14:55 -0400
              Re: fetching all items at once - how do you code to display them? Doug Miller <doug_at_milmac_dot_com@example.com> - 2015-04-06 02:07 +0000
          Re: fetching all items at once - how do you code to display them? Doug Miller <doug_at_milmac_dot_com@example.com> - 2015-04-06 02:05 +0000

csiph-web