Jump to content

[SOLVED] explode() troubles or maybe foreach trouble


bluebyyou

Recommended Posts

I keep track of who is in a photo by storing the users id in the DB by comma separated values. Then I grab them back out with this:

 

$tag = explode(",",$picturetag);
foreach ($tag as $number)
	{
	if (in_array($number,$row))
		{
		$query2 = "SELECT fname,lname FROM `member` WHERE `memberid` = $number";
		query_db2($query2);
		$row2 = mysql_fetch_array($result2);
		echo "<a href='profile.php?id=$number'>$fname $lname ($number)</a><br />";

		}
	}

 

$picturetag is the column in the DB that stores the comma separated values

 

So the problem I am having is that only two of my users are displayed. It will display the same user multiple times, but if it is a user other than the two they wont be shown.

 

On this page http://www.wiuartinny.com/pic.php?id=38 you can see the "in this photo section.

I have also echoed the entire picturetag field to show what users should be displayed.

try

<?php
$query2 = "SELECT fname,lname,memberid FROM `member` WHERE `memberid` IN ($picturetag)";
$result2 = mysql_query($query2) or die (mysql_error()."<p>$sql</p>");
while (list($fname, $lname,$number) = mysql_fetch_row($result2))
{
    echo "<a href='profile.php?id=$number'>$fname $lname ($number)</a><br />"; 
}
        
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.