Jump to content

Search Results and Pictures


TheNotebook

Recommended Posts

Hi guys,

 

A beginner at php/mysql here...

 

For a project I'm doing, I would like to display search results with an image, small description, then a 'read more' link.

After googling this issue, I can't find much information on it, which surprised me.  Someone did mention blobs for images... (whatever they are!)

I'm wondering if anyone knows of any tutorials, or has any code to do this?

 

Your help is much appreciated.

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/232955-search-results-and-pictures/
Share on other sites

mmmmm

ok blobs are binary large object, essentially what an image is if its stored into a db, alternatively images can be just saved on the server in a folder.

 

first off you should build a search form, that posts to a results page (or itself)

then pull the information from the form, and take that to put into your mySQL search statement.

then parse the results accordingly

roughly something like this:

 

$search = $_POST['searchinput']

 

$sql = "SELECT * FROM Tbl_BLah WHERE `Something` LIKE '%$search';"

 

//i skip now to results loop, assume $row is my dataset aray

echo "<img src='" . $row['image'] . "'>";

echo "<a href='details.php?id=" . $row['id'] . "'>Click for more info</a>";

echo "<br>" . $row['smalldescription'] ;

Thanks for your help!

 

I've managed to get it working, but it only shows one row of results... (it should show 3)

At the moment, each entry in mysql has a different ID.... To overcome this, would I need the entrys from same music artist to have the same ID?

Right.. I've done that... to connect it all to my database, I've written this...

 

$query = "SELECT image, artist, smalldescription, link FROM adatabase.albums, artists WHERE

artist.ID = album.ID LIKE '$artist' order by album";

 

However, when I search it says there are no databases selected?!

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.