php mysql array question

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default Re: php mysql array question

    I use the PEAR db [url]http://pear.php.net/manual/en/package.database.php[/url]

    This returns arrays - examples here
    [url]http://pear.php.net/manual/en/package.database.db.intro-fetch.php[/url]

    look at the Quick data retreaval down the page

    pete


    Larry Brown wrote:
    > Is there any php function to pull a query into an array? I know there is a
    > way to get the first row of the results in an array, but I'm having to loop
    > through each row pushing the row onto an array to get the result I'm looking
    > for and it seems like a lot of code for something that I would think is used
    > a lot.
    >
    > Larry S. Brown
    > Dimension Networks, Inc.
    > (727) 723-8388
    >
    >
    Pete Morganic Guest

  2. Similar Questions and Discussions

    1. mySQL and Array
      Hi all- I have defined an array using: <cfset notesattached = ArrayNew(1)> and added some data like this: <cfset notesattached = 4>...
    2. MySQL Table Question > Array?
      I'm programming a Gaming Ladder/Tournament system. Let's say I have the following tables: PLAYERS ------- * Player_ID * Player_name .... *...
    3. array question (grep -v on array)
      Hi, I have an output of errors fed into an array, after which I only look at things I care about and put them in a different array: ...
    4. HOW TO -- ARRAY UPDATE MYSQL
      HI ALL, I want to update a mulitple row from a HTML Table to MYSQL Database. L1 V1 T1 L2 V2 V2 L3 V3 V3 Any help in this regard is much...
    5. [PHP] php mysql array question
      > Is there any php function to pull a query into an array? I know there is a loop looking used There's no PHP function to do so. Some...
  3. #2

    Default Re: php mysql array question

    It shouldn't take a lot of code to put results into an array:
    $query = "select * from table";
    $r = mysql_result($query);
    while ($row = mysql_fetch_object($r))
    $hold[] = $row;
    (OR, to index by some id field in the database:)
    $hold[$row->id] = $row;
    mysql_free_result($r);

    Total of 5 lines.

    -- Rob




    "Larry Brown" <larry.brown@dimensionnetworks.com> wrote in message
    news:CBECIONKKLMDDCIKHALJAECJIAAA.larry.brown@dime nsionnetworks.com...
    > Is there any php function to pull a query into an array? I know there is
    a
    > way to get the first row of the results in an array, but I'm having to
    loop
    > through each row pushing the row onto an array to get the result I'm
    looking
    > for and it seems like a lot of code for something that I would think is
    used
    > a lot.
    >
    > Larry S. Brown
    > Dimension Networks, Inc.
    > (727) 723-8388
    >
    >

    Rob Adams Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139