Hi,
This is what i am doing, querying a database via a select statement (getting
max 5 records), then dumping everything into an associative array. And then
assign the arrays value to a variable for easier readibility and usability
like so:

if(!($rs = mysql_query($q))) // querying
  { echo "Query failed". mysql_error(); exit; }


   $n = 0;
  while ($line = mysql_fetch_assoc($rs)) { //dumping into an array
    foreach ($line as $field => $value) {
      $data[$field][$n] = $value;
    }
    $n++;
  }

and this is how i use the arrays values (blah is the field name):
$blah1=$data['blah'][0];
$blah2=$data['blah'][1];
$blah3=$data['blah'][2];

The problem is I have 38 fields and i can get upto 5 records.... that means
i will end up with over 150 of these statements:
$blahn=$data['blah'][n];
and since i dont want to go all over my script saying "echo
$data['blah'][n];" is there an easier way to avoid the 150 possible
statements? maybe via a for loop or something? Am feeling braindead right
now after sitting on the comp for 7hrs straight.

Any and all suggestions welcome. When/If replying please give me a code
example of what you say as I may not understand you.

Thanks,
-Ryan


We will slaughter you all! - The Iraqi (Dis)information ministers site
http://MrSahaf.com



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to