Thread: Array Problems

  1. No Profile Picture
    Devshed Newbie (0 - 499 posts)
    I'm very new at this.

    I need $id, $mark and $serie to be arrays which I thought they would be. But when I test with is_array() it return false. What should I do to make each one an array.

    $MyQuery = "SELECT * FROM Serie";
    while ($row = mysql_fetch_array($result))
    $id = $row["ID"];
    $mark= $row["Mark"];
    $serie= $row["Serie"];
  2. #2
  3. No Profile Picture
    Devshed Newbie (0 - 499 posts)
    Change the variable assignments to look like this:

    $id[] = $row["ID"];
    $mark[] = $row["Mark"];
    $serie[] = $row["Serie"];

    The empty brackets indicate that the variable is to be handled as an array, and the first value given will go into the 0 element of that array. If you make another assignment with empty brackets, the value will go into the 1 element, instead of overwriting the 0 element.

    Or of course you can specify which element you want assigned if necessary.

Similar Threads

  1. Problems calling an array value
    By gursharn in forum PHP Development
    Replies: 4
    Last Post: February 16th, 2004, 12:42 PM
  2. array problems
    By gallafrax in forum PHP Development
    Replies: 2
    Last Post: February 2nd, 2004, 07:52 AM
  3. sort: find duplicate string elements in array
    By sciencelife in forum Java Help
    Replies: 3
    Last Post: January 27th, 2004, 01:29 PM
  4. C++ programming help.
    By Programming1 in forum C Programming
    Replies: 1
    Last Post: January 20th, 2004, 10:47 AM
  5. Problems with array
    By deerslayer in forum Visual Basic Programming
    Replies: 3
    Last Post: December 5th, 2003, 10:59 PM

IMN logo majestic logo threadwatch logo seochat tools logo