Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

PHP - storing query results as array

Options
  • 23-01-2006 3: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 Posts: 68,317 ✭✭✭✭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