Announcement

Collapse
No announcement yet.

Simple sql query -> array problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Simple sql query -> array problem

    I have the following:

    Code:
      ..
     $sql = "select status, count(*) from catalog where userid='$userid' group by status;";		 
      $result = @mysql_query($sql,$connection) or die("Search not succesful");
      while ($haku=mysql_fetch_array($result)) 
      {
      .....
      }
    Results of that:

    | status | count(*) |
    | Foo1 | 2 |
    | Foo2 | 4 |

    What should I put between { and } so that I could use later something like
    $foo1 = 2
    $foo2 = 4

    An array?... How?

  • #2
    Ok, I was able to solve that by myself - of course soon after I posted that message above

    Code:
     $sql = "select status, count(*) as stats from catalog where userid='$userid' group by status;";
     $result = @mysql_query($sql,$connection) or die("Haku ei onnistunut");
     $i=0;
     while ($haku=mysql_fetch_array($result)) {
     $luvut[$i] = $haku["stats"];
     $i++;
     }
    Is there a better or more efficient way to do this?

    Comment

    widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
    Working...
    X