Re: First record of array not being echoed

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

 



It seems to me that the first time you go through the loop, if
$record->wave_num is != $prior_wave then you print the wave number but
not the person's name--but you already have a record there with a
person's name!

Try taking out the else statement--if you follow the code from there you
should be able to fix it up.

Of course, I'm also doing this by just looking at your code, so I may be
wrong (the odds are not in my favor) :-)

On Mon, 2002-10-14 at 07:58, Rankin, Randy wrote:
> Good morning all.
> 
> I am attempting to create a table in which there is a title cell populated
> with a training wave number and then I would like to echo all members of
> each training wave below the title cell (See example below for
> clarification). All seems to be working with one exception. The first record
> of each array is not being echoed. If I run the query in MySQL, all rows are
> returned, so it must just be something I am not seeing in the code (which is
> posted below). Thanks in advance for any help.
> 
> Randy
> 
> ----------------------  START EXAMPLE ---------------------------
> 
> 	
> 	Training Wave: I-02   
>  
>   	Brumley, Kennith 
>   	Dillard, Lori 
>   	Hamilton, Don 
>   	Larsen, Gerry 
>   	Robinson, Bobby 
>   	Sarabi, Ray 
>   	Shaddix, Kirby 
>   	Springer, Leon 
>  
>  	Training Wave: II-02   
>  
>   	Boles, Scooby 
>   	Deloney, Jerald 
>   	Russell, Roger 
>   	Smith, Martha 
>   	Stockman, Joe 
>   	Williams, Ed 
> 
> 	ETC, ETC, ...
> 
> ----------------------  END EXAMPLE ---------------------------		
> 
> --------------------  BEGIN CODE SNIPET ---------------------------------
> <?
> $sql = "SELECT u.last_name, u.first_name, w.wave_id, w.wave_num
> 	FROM USERS u, WAVES w
> 	WHERE w.wave_id = u.wave_id
> 	AND u.plant_id = '$plant_id'
> 	ORDER BY w.wave_id ASC, u.last_name ASC";
> 
> $result = db_query ( $sql );
>     
> for ( $i = 0; $i < db_num_rows ( $result ); $i++ )
>     	{
>     	$record = db_fetch_object ( $result );	
>     		
>     	if ( $record->wave_num != "$prior_wave" )
> 	{
> 		$prior_wave = $record->wave_num;
> 				
> 		?>
> 				
> 			<table width="375" cellpadding="0" cellspacing="0"
> border="0"> 
> 				<tr>
> 				 	<td colspan="2" height="10"><?php
> echo FILLER; ?></td>
> 				</tr>
> 				<tr height=20 bgcolor="<? echo $color2; ?>">
> 				 	<td><b
> class="bGray"><b>&nbsp;Training Wave: <? echo $prior_wave; ?></b></td>
> 				 	<td align="right">&nbsp;</td>
> 				</tr>
> 				<tr>
> 				 	<td colspan="2" height="10"><?php
> echo FILLER; ?></td>
> 				 </tr>
> 				</table>  
> 				
> 		<?
> 	}
> 	else
> 	{
> 		?>
> 				
> 			<table width="575" cellpadding="0" cellspacing="0"
> border="0"> 
> 				<tr>
> 					<td>&nbsp; <? echo
> $record->last_name . ", " . $record->first_name; ?></td>
> 				</tr>
> 			</table>
> <?
> 	}
> 
>    }	
> }
> }
> ?>
> 
> -------------------------  END CODE SNIPET
> -------------------------------------------------



-- 
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