Re: help w/ multidementional array in mysql

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sorry for accidentally posting twice:

I wanted to point out a typo.
At the bottom I meant "advancing the array" not "table" in regards to next()



On Wed, 25 Feb 2004 11:12:10 -0600
"PHELPS, SCOTT" <SPHELPS@xxxxxxxxxxxx> wrote:

> 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)
> 
> 
> -- 
> Scott Phelps
> Regional IT Manager
> Ridgway's, LTD.
> 5001 Cleveland Street
> Virginia Beach, VA  23462
> 757-490-2305
>  
> ---
> Linux: "$ su - root"  -->  Windows: (reboot)
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


-- 
Scott Phelps
Regional IT Manager
Ridgway's, LTD.
5001 Cleveland Street
Virginia Beach, VA  23462
757-490-2305
 
---
Linux: "$ su - root"  -->  Windows: (reboot)

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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux