SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard geiger's Avatar
    Join Date
    Jul 2001
    Posts
    2,459
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to use values after grabbing, without while()

    Typically I'll use a while(mysql_fetch_array()) to output values in rows. For my current purposes, I'd like to display them in a little bit more complex a way. I'd like to pull all the values with mysql_fetch_array() and then, after they're all in a big array, output certain values individually.

    For instance, here's the query I have right now. It has 12 or so rows:
    $modelsQUERY=mysql_query("SELECT cars, median, mean, q1, q3, error, sd FROM models ORDER BY model ASC");

    Then I'd like to be able to output, for instance: $models['accord']['q1'] or $models['civic']['error']

    How would I go about doing this?

    P.S. I have another MySQL question that I accidentally posted in the wrong forum: http://www.sitepoint.com/forums/showthread.php?t=288140

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,270
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    this one's in the wrong forum too -- moving to PHP

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Addict Shockt's Avatar
    Join Date
    Jan 2005
    Location
    California
    Posts
    360
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try something like this:
    PHP Code:
    <?

    $modelsQUERY
    =mysql_query("SELECT cars, median, mean, q1, q3, error, sd FROM models ORDER BY model ASC");
    while(
    $model mysql_fetch_array($modelsQUERY))
    {
      
    $models['$model['carModelName']'] = $model;
    }

    ?>


Bookmarks

Posting Permissions

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