Jump to content

displaying more images


cosmicsea

Recommended Posts

Hello I am using this script right here

http://www.nearby.org.uk/sphinx/search-example5-withcomments.phps

and am trying to show images from my db but I can only get it to show the first image. Does anyone know how to make it show all images if images even exist for that particular search result?

 

I changed the query to

$CONF['mysql_query'] = '
SELECT l.link_id AS id, l.title AS title, l.fulltxt AS body, l.url AS url, m.media_id AS im_id, m.title AS im_title, m.thumb_link AS im_t_link
FROM search1_links AS l LEFT JOIN search1_media AS m ON (m.link_id = l.link_id)
WHERE l.link_id IN ($ids)
';

 

and added

 

			if ($row['im_id']) {
			echo '<img src="'.($row['im_t_link']).'" height="100px" width="100px"> ';
		}

right here

 

            //Actully display the Results
            print "<ol class=\"results\" start=\"".($currentOffset+1)."\">";
            foreach ($ids as $c => $id) {
                $row = $rows[$id];
                
                $link = htmlentities(str_replace('$id',$row['id'],$CONF['link_format']));
                print "<li><a href=\"$link\">".htmlentities($row['title'])."</a><br/>";
                
                if ($CONF['body'] == 'excerpt' && !empty($reply[$c]))
                    print ($reply[$c])."</li>";
                else

           if ($row['im_id']) {
			echo '<img src="'.($row['im_t_link']).'" height="100px" width="100px"> ';
		}

                    print htmlentities($row['body'])."</li>";
            }
            print "</ol>";
            
            if ($numberOfPages > 1) {
                print "<p class='pages'>Page $currentPage of $numberOfPages. ";
                printf("Result %d..%d of %d. ",($currentOffset)+1,min(($currentOffset)+$CONF['page_size'],$resultCount),$resultCount);
                print pagesString($currentPage,$numberOfPages)."</p>";
            }

 

Can anyone help me to be able to display all images if they exist? Thanks.

Link to comment
Share on other sites

I have tried that and it doesn't work, it will repeat images and stack results over each other and also lock up my browser trying to get the result page to show. I have a sloppy way of doing this by adding more loops and changing the code a bit but its slower than what I want and was trying to figure out an easier way to do this without having to drastically change the code.

Link to comment
Share on other sites

the actual line should to do it should be something like

 

while ($row=mysql_fetch_array($CONF)) {
echo '<img src="'.($row['im_t_link']).'" height="100px" width="100px"> ';
}

 

this would echo 1 image for every result found, I made a mistake before with the while loop on the image as that is true it would put you in an endless loop, this one will not do that unless there are endless results in your database

Link to comment
Share on other sites

I cannot seem to get it to display unless I am using

if ($row['im_id']) {

echo '<img src="'.$row['im_t_link']).'" height="100px" width="100px" title="{$row[im_title]}"> ';

}

which will display 1 result but I need all if they exist. I have tried several variations of while and cannot get a result from it. I can make this really sloppy and use an else statement with different code after the loop to display all images but then I cannot get other things to display properly because the way it is looped is terrible. I don't know what to do, this is driving me nuts. It seemed like such a simple thing but is now turning into a mess.

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.