help w/ multidementional array in mysql
| From: | PHELPS, SCOTT | Date: | Wed, 25 Feb 2004 17:04:43 +0000 |
| Subject: | help w/ multidementional array in mysql | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-33120@lists.php.net to get a copy of this message | ||
Thanks in advance for reading this:
I am trying to take a query based on user input and selectively output
fields to a table.
Heres the query code:
<<< snip - snip>>>
$query_result = mysql_query($query);
while ($field = mysql_fetch_array($query_result))
{
$returned_rows =
array(
array(
"id"=>$field['id'],
"lastname"=>$field['lastname'],
"firstname"=>$field['firstname'],
"yearhired"=>$field['yearhired'],
"yeardepart"=>$field['yeardepart']
)
);
}
<<< snip - snip>>>
Now what I want to do is put only the lastname and firstname in a
small table with alternating colors:
Like this:
-----------------------------------------
| $lastname, $firstname | ---> color=blue
-----------------------------------------
| $lastname, $firstname | ---> color=white
-----------------------------------------
| $lastname, $firstname | ---> color=blue
-----------------------------------------
Heres the code:
<<< snip - snip>>>
<table class="results_inner">
<?php
foreach ($returned_rows as $value)
{
printf ("<tr><td class='results_blue'>%s,
%s</td></tr><br>", $value['lastname'],
$value['firstname']);
next($returned_rows);
printf ("<tr><td class='results_white'>%s,
%s</td></tr><br>", $value['lastname'],
$value['firstname']); }
}
?>
</table>
<<< snip - snip>>>
The problem is that it only prints one name. Also next() doesn't seem to be advancing the
table so
I am getting duplicates of the one name it does print to the table
Thanks.
--
Scott
--
Scott Phelps
Regional IT Manager
Ridgway's, LTD.
5001 Cleveland Street
Virginia Beach, VA 23462
757-490-2305
---
Linux: "$ su - root" --> Windows: (reboot)