Hi guys,

lets say I have a table of employees

id
name
position
salary

and I wanted to dump all records where id in(1,2,3,4) into a multidimensional array

array[0][0] = emp1 id
array[0][1] = emp1 name
array[0][2] = emp1 posistion
array[0][3] = emp1 salary
array[1][0] = emp2 id
array[1][1] = emp2 name
array[1][2] = emp2 posistion
array[1][3] = emp2 salary

and so on..

how can I do this ?

thanks in advance

    What have you tried?

    Seems like a simple matter of SELECT'ing the desired rows and storing them in a multi-dimensional array.

      $sql = "SELECT id, name, position, salary FROM table WHER id IN(1,2,3,4)";
      $result = mysql_query($sql);
      $data = array();
      // use mysql_fetch_assoc() instead if you want field names for 2nd array key:
      while($row = mysql_fetch_row($result)) {
         $data[] = $row;
      }

        This function executes SQL query and retrieves entire result table as two-dimensional array.These two methods return multi-dimensional arrays..I want to store the results of a MySQL query as a multidimensional array.

        software developer leeds

          Write a Reply...