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


Groups > comp.lang.php > #15210

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

From Jerry Stuckle <jstucklex@attglobal.net>
Newsgroups comp.lang.php
Subject Re: fetching all items at once - how do you code to display them?
Date 2015-04-05 11:21 -0400
Organization A noiseless patient Spider
Message-ID <mfrjrc$kbm$1@dont-email.me> (permalink)
References <46bui2hdar3f$.1qryyy3zcx5um.dlg@40tude.net> <mfps3p$j9e$1@dont-email.me> <1lpvv6118algy.1pzxv594x426f$.dlg@40tude.net> <mfqeo9$va3$1@dont-email.me> <1xbslhz79f19i.1tpyrouzu9o3f$.dlg@40tude.net>

Show all headers | View raw


On 4/5/2015 10:58 AM, richard wrote:
> On Sun, 5 Apr 2015 04:47:05 +0000 (UTC), Denis McMahon wrote:
> 
>> On Sat, 04 Apr 2015 19:32:29 -0400, richard wrote:
>>
>>> On Sat, 4 Apr 2015 23:28:57 +0000 (UTC), Denis McMahon wrote:
>>>
>>>> On Fri, 03 Apr 2015 21:54:12 -0400, richard wrote:
>>>>
>>>>> "SELECT * from sixty where (
>>>>>   (peak='1')
>>>>>   AND  (year>1959)
>>>>>   AND  (year<1970)
>>>>> ) ORDER BY year, sid "
>>>>>
>>>>> Considering this code provided by Erwin Moller, how does one now
>>>>> display the information?
>>>>>
>>>>> The standard method of using $row=$result() winds up with only the
>>>>> first item ending up in a displayed table while the other items are
>>>>> just bunched up together one after the other.
>>>>>
>>>>> If I simply fetch one item at a time, the table is displayed as
>>>>> wanted.
>>>>>
>>>>> By this usage of the word "table" I am not speaking of the database
>>>>> table stored on the server. But the html displayed table on the page.
>>>>
>>>> Note that the following is an example that assumes the reader has some
>>>> competencies and understanding of php, and the use of the ellipsis
>>>>
>>>> <?php
>>>>
>>>> // Start the table:
>>>>
>>>> echo "<table>\n";
>>>>
>>>> // print the table header row
>>>>
>>>> echo "<tr> <th>header</th>... </tr>\n";
>>>>
>>>> // use a loop that fetches every row from the mysqli result // this
>>>> example assumes the mysqli result is in $result // $data is a local
>>>> variable in the loop
>>>>
>>>> while ($data = mysqli_fetch_assoc($result)) {
>>>>
>>>> // in here you write out a single table row for each set of // $data
>>>> from the query result
>>>>
>>>> echo "<tr> <td>{$data['fieldname']}</td>... </tr>\n";
>>>>
>>>> }
>>>>
>>>> // close the table
>>>>
>>>> echo "</table>";
>>>>
>>>> ?>
>>>
>>> Done that.
>>> What I get is 11 duplicates of the first item.
>>> So why does it stop at 11 when I have 200 records?
>>
>> Perhaps your query is not fetching the data you think it is. Without 
>> running your query against your datatable at the mysql command line, it's 
>> hard to tell.
>>
>> I suspect but I can't be sure that the reason you're getting 11 values 
>> might be linked to the "(year>1959) AND (year<1970)" part of the query.
>>
>> There might be an issue if you have stored years as strings and are now 
>> trying to compare those strings with a numeric value. I'm not sure, 
>> because I don't usually try to compare strings with numbers in mysql.
> 
> I tried using the "between" part and that resulted in displaying "0".
> 

Which goes back to Denis's original comment - how is the 'year" column
defined in your database?

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

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