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
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'] ;

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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?!

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.