Hello,

I am trying to show a list of information using a FETCH and WHERE statements.

This is my code:

$buds = mysql_query("SELECT * FROM buds2 WHERE bud_me = '$userid' AND confirmed= '1'");

$x = 1;
while ($array = mysql_fetch_array($buds))
{
	$buddy = fetch("SELECT display_name,username FROM members2 WHERE id = '$array[bud_you]' AND game = '$game'");
	
	$buddy2 = fetch("SELECT photo_selected,location,my_update FROM members_profiles2 WHERE username = '$buddy[username]' AND game = '$game'");




	if (!$array[bud_note]) { $array[bud_note] = "<i>No notes on this buddy.</i>"; }

	$mybuds .= "
	<TABLE CELLSPACING=5 CELLPADDING=0 WIDTH=95% BGCOLOR=\"$reallyLight\">
		<TR>
			<TD VALIGN=top><center>
			 <P><a target=_blank href=user_profile.php?user=$buddy[username]&game=$game><FONT SIZE=\"+1\"
color=#000000><b>$buddy[display_name]</b></FONT></a><p>
			 <BR><img src='photos/$buddy2[photo_selected]' width=80 ><FONT SIZE=\"-1\"><I>
			 <a href=buds_edit.php?game=$game&bud=$array[bud_you]>Edit</a>,
		     <a href=delete_bud.pro.php?game=$game&bud=$array[bud_you]><font
color=red>Remove</font></a></I></FONT>
			 </P>
			 <P><font size=-1><B>Notes:</B> $array[bud_note]</font></P>
			</TD>
		</TR>
	</TABLE><br>";
}

I can get this code to work normally WITHOUT using the WHERE confirmed='1' code but whenever I try to use this it just doesnt show anything from the table!

Please Help

Many Thanks

Hmm dunno how but there is an extra confirmed in this line of code:

$buds = mysql_query("SELECT * FROM buds2 WHERE bud_me = '$userid' AND confirmed= '1'");

This is only ONE AND confirmed in the code!

I see all your ID's are quoted. If they are integers, they shouldn't be. Only strings and string-like data should be quoted.

I also can not find any reference to the fetch() function you are using. Is this something you made, or from some 3'rd party include?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.