Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

PHP - storing query results as array

  • 23-01-2006 03:00PM
    #1
    Closed Accounts Posts: 2


    I'm a relative newbie to PHP and I'm having an absolute brain-freeze this morning and can't think of a way around this.

    I'm selecting one field from a DB using a SQL query. I'll be getting about 7-10 records for this query and I want to store them as an array.

    I know it's simple to use mysql_fetch_array to store a row of results, but can anybody help me to store a number of records into an arary.

    I'm sure there's a really obvious solution for this, but I just can't think straighht this morning and can't seem to find anything relative by Googling...

    Thanks


Comments

  • Closed Accounts Posts: 2 southpaw7


    The obvious solution to this eventually dawned on me.

    Once I figure out how to delete this thread I'll stop hogging the bandwidth - thanks.


  • Registered Users, Registered Users 2 Posts: 68,173 ✭✭✭✭seamus


    No need to delete. If you can post your solution, someone else can benefit.

    Personally, I'd just do
    [php]
    $values = array();
    while($row = mysql_fetch_array($result)) {
    array_push($values, $row);
    }
    [/php]
    Depending on how you want to use the array of course.


Advertisement