Jump to content

[SOLVED] Combining Data in a php loop


Leosan

Recommended Posts

Hi, I am creating a gallery software but have come across a few problems with the search feature. The search feature works by matching the search term against a tag's field for an image.

 

The search feature itself works fine, but I want to display all of the tags used on a gallery page next to the images, to make search easier, problem is with the actuall tags.

 

an example tag field would contain a string of such " Futurama, Cartoon, Funny, Zoidberg". When displaying the image, that string is sperated using php explode feature, and is passed through a function which makes it a clickable search.

 

Problem is, on the page where several images are displayed, I need to find a way of conbining the tags field of all the images displayed on that page, and thats where I am having an issue.

 

Following is the section of code dealing with displaying the image, its here where I need to get the tags to combind

 

 

$rowclass = 0;
while ($row = mysql_fetch_array( $imagesql )) {


$counta++;
if ($counta % 4 == 0) {
$tr1 =  "</tr><tr>";
}
else
{
$tr1="";
}

$aid = $row['id'];


$tagin  = $imgrow['tags'];


$url = '?s=gallery&v='.$row['id'].'';

$ParseArray = array(
"NAME"     => $row['name'], 
"TR"     => $tr1, 
"DEL" => $del,
"FILE" => $row['file'],
"URL"     => $url, 
"CLASS" => $rowclass
);

TEMPLATE CODE HERE

$rowclass = 1 - $rowclass;
$listtags = "$listtags,$tags";

}

 

Any help would be appreciated as this is doing my head in. Basically, in the loop I want it to update the $listtags variable each time, adding on the new tags so I can use the variable lower on the page for an explode and list of tags.

Link to comment
Share on other sites

I see that you do this:

$listtags = "$listtags,$tags";

Which would work, but I don't see that $tags has any value, did you mean $row['tags']? If so, you might want to try something like this:

 

$listtags .= ',' . $tags;

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.