TheNotebook Posted April 7, 2011 Share Posted April 7, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/232955-search-results-and-pictures/ Share on other sites More sharing options...
spiderwell Posted April 7, 2011 Share Posted April 7, 2011 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'] ; Quote Link to comment https://forums.phpfreaks.com/topic/232955-search-results-and-pictures/#findComment-1198138 Share on other sites More sharing options...
TheNotebook Posted April 7, 2011 Author Share Posted April 7, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/232955-search-results-and-pictures/#findComment-1198172 Share on other sites More sharing options...
spiderwell Posted April 7, 2011 Share Posted April 7, 2011 yes you would want 2 tables say, one with artists, the other with songs, and use the primary key of artists to link to songs to identify all songs by that artist Quote Link to comment https://forums.phpfreaks.com/topic/232955-search-results-and-pictures/#findComment-1198174 Share on other sites More sharing options...
TheNotebook Posted April 7, 2011 Author Share Posted April 7, 2011 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?! Quote Link to comment https://forums.phpfreaks.com/topic/232955-search-results-and-pictures/#findComment-1198195 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.