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
https://forums.phpfreaks.com/topic/166199-solved-combining-data-in-a-php-loop/
Share on other sites

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.