Leosan Posted July 16, 2009 Share Posted July 16, 2009 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 More sharing options...
Alex Posted July 16, 2009 Share Posted July 16, 2009 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 https://forums.phpfreaks.com/topic/166199-solved-combining-data-in-a-php-loop/#findComment-876398 Share on other sites More sharing options...
Leosan Posted July 16, 2009 Author Share Posted July 16, 2009 I removed tags prior to posting, I found that the array was wrong. I messed up big time usign $imagerow['tags'] and didnt realise i had changed it to just $row Thanks anyway Link to comment https://forums.phpfreaks.com/topic/166199-solved-combining-data-in-a-php-loop/#findComment-876430 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.