Link to home
Start Free TrialLog in
Avatar of only1wizard
only1wizardFlag for United States of America

asked on

pulling double the amount of records

i have double while loops and the data that is returning is being returned in double amounts.

thanks in advance for your help!

Theo Werntz II

here is the code:

<?php
mysql_select_db($database_Del_Comments, $Del_Comments);
$result = sprintf("SELECT a.Id, a.Type, 
a.Dates, 
a.UIdFk as UIdFk, 
b.Id as Did, 
b.comment as Comment, 
b.dates as Day, 
b.sfk as Sfk ,
c.sfk as sfk1, 
d.Memo as Memo,
d.Date as Dates1,
aes_decrypt(e.ProfileName, '$Ukey') as Name,
substr(i.Path, 4) as Path
FROM 
asstatusupdate as a   
left join asstatusdata as b 
on a.id = b.sfk 
left join asmanystatusupdate as c
on b.sfk = c.sfk
left join ascomments as d
on d.id = c.cfk
right join ASWebInfo as e
on e.Uidfk = a.uidfk
right join ASManyAlbums as f
on f.UserId=a.uidfk
right join ASAlbums as g
on f.AlbumId=g.Id
right join ASTitle as h
on g.Id=h.AlbumId
right join ASData as i
on h.Id=i.TitleId
where a.uidfk in (select friendid from asfriends where uidfk0='1') and i.DefaultProfilePic='Y' order by dates desc;
");
$statusUpdate = mysql_query($result, $Del_Comments);

$category_id = '';

while($row = mysql_fetch_array($statusUpdate)) {
	if ($row['Id'] != $category_id) {
		$category_id = $row['Id'];
	
	// grab table variables	
	    $Type = $row['Type'];
		$Dates = $row['Dates'];
		$Comment = $row['Comment'];
		$Name = $row['Name'];
		$Path = $row['Path'];
		$FriendId = $row['UIdFk'];
		$SFK = $row['Sfk'];
		
		echo '<table align="center" width="40%" border="3" cellpadding="0" cellspacing="0">'; 
		echo '<tr>';
		echo '<td align="center">'; echo "$Name"; echo "<br/>"; echo  '<a href="source/source.php?FriendId=' ."$FriendId". '"><img src="' ."$Path". '" height="120" width="120" align="middle" border="3" /></a>'; echo '</td>';
		echo '<td align="center"> '; echo "$Dates" ; echo "<br/>"; echo "<br/>"; echo "$Type"; //echo "</td>";
	    echo "<br/>"; 
		 echo "$Comment"; echo '</td>'; // echo "</br>";
		echo '<td>'; echo "$category_id" ; echo '</td>';
		echo '<td>'; echo "$SFK"; echo '</td>';
		echo '</tr>';
	    echo '</table>';

		
	
	
} // end of if
mysql_select_db($database_Del_Comments, $Del_Comments);
$comments= sprintf("SELECT 
c.sfk as sfk1,
c.UIdFk0,
d.Memo as Memo,
d.Date as Dates1,
aes_decrypt(e.ProfileName, '$Ukey') as Name,
substr(i.Path, 4) as Path
FROM 
asmanystatusupdate as c
left join ascomments as d
on d.Id = c.CFk
right join ASWebInfo as e
on e.UIdFk = c.UIdFk0
right join ASManyAlbums as f
on f.UserId=c.UIdFk0
right join ASAlbums as g
on f.AlbumId=g.Id
right join ASTitle as h
on g.Id=h.AlbumId
right join ASData as i
on h.Id=i.TitleId
where c.sfk={$row['Sfk']} AND c.UIdFk0 in (select FriendId from asfriends where UIdFk0='1') and i.DefaultProfilePic='Y' order by dates desc;
");
$status_comments = mysql_query($comments, $Del_Comments) or die(mysql_error());
while($user_row = mysql_fetch_array($status_comments)){
	       // test the query
			//if($row['sfk'] == $user_row['sfk']) {
			{
				
			$Dates1 = $user_row['Dates1'];
			$Memo = $user_row['Memo'];
			$Name1 = $user_row['Name'];
			$Path1 = $user_row['Path'];
			$FriendId1 = $user_row['UIdFk0'];
			$SFK1 = $user_row['sfk1'];
			
			// display table
			
			
			echo '<table align="center" width="40%" border="3" cellpadding="0" cellspacing="0">'; 
		echo '<tr>';
		echo '<td align="center">'; echo "$Name1"; echo "<br/>"; echo  '<a href="source/source.php?FriendId=' ."$FriendId1". '"><img src="' ."$Path1". '" height="120" width="120" align="middle" border="3" /></a>'; echo '</td>';
		echo '<td align="center"> '; echo "$Dates1" ; echo "<br/>"; echo "<br/>"; //echo "</td>";
	    echo "<br/>"; 
		 echo "$Memo"; echo '</td>'; // echo "</br>";
		echo '<td>'; echo "$SFK1"; echo '</td>';
		echo '</tr>';
	    echo '</table>';

				
				
			 } // end of if
	
	} // end of while loop
}// end of main loop

?>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of only1wizard
only1wizard
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of only1wizard

ASKER

i've found the soluton