0

Don't ask me why I need it, I've tried to find it on the web and have failed. I need it to find rows of info on my database and per row it creates a array with one row and stores that array in an array and carries on with the rest of the rows.

I will then generate a new word doc per array found in the array of arrays( I can do this myself.) I'm sorry I don't make much sense, I don't really know how to explain this...

2
  • I looks pretty straightforward unless I am missing something. What specifically is a problem for you? Commented Oct 9, 2011 at 15:07
  • That's common practice I'd say. Have a look at the documentation for a start: php.net/manual/en/function.mysql-fetch-array.php Commented Oct 9, 2011 at 15:08

1 Answer 1

1

Do you mean:

$sql = "SELECT * FROM tbl";
$query = mysql_query($query, $connection);

$rows = array(); 
while ($row = mysql_fetch_array($query)) {
  $rows[] = $row;
}

// You now have an array of your DB rows in $rows

foreach ($rows as $row) {
  createWordDoc($row);
}

If you don't actually need to cache the rows you could do this directly in your first loop of course:

$rows = array(); 
while ($row = mysql_fetch_array($query)) {
  createWordDoc($row);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.