The issue:
I have read several different methods of referencing an image inside of your database and then using php to display the image in my results page but so far none of the methods work for me. I would prefer to not put the image inside of the database and instead use a reference link to an image folder server side. So basically adding a column to the tables I already have with the image urls seems like the best option. But with the code I currently have I have no idea how to reference a particular image to display along side the "names" and "information" columns that are already being displayed properly. Anyone have any suggestions on an easy way to do this without destroying the code I have already written?
This is 1/4 of the code (that queries the table "classes") as the rest is just else if statements to switch between tables.
<?php mysql_connect("localhost", "root", "") or die("Error connecting to database: ".mysql_error()); /* localhost - it's location of the mysql server, usually localhost root - your username third is your password if connection fails it will stop loading the page and display an error */ mysql_select_db("xaviorin_skyrim") or die(mysql_error()); /* tutorial_search is the name of database we've created */ ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Search results</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="style2.css"/> <embed src="Skyrim- Peter Hollens & Lindsey Stirling.mp3" autostart="true" loop="true" width="2" height="0"> </embed> </head> <body> <?php $Options = $_POST['submit']; //value sent from submit drop down menu $classes_status = 'unchecked'; //all possible values start as unchecked $powers_status = 'unchecked'; $skills_status = 'unchecked'; $shouts_status = 'unchecked'; if (isset($_POST['submit'])) {//if submit pressed check $Options = $_POST['Options'];//post from index radio value if ($Options == 'classes') {//if radio = classes $classes_status = 'classes checked'; //change variable to classes checked $query = $_POST['query']; // gets value sent over search form $min_length = 3; // you can set minimum length of the query if you want if(strlen($query) >= $min_length){ // if query length is more or equal minimum length then $query = htmlspecialchars($query); // changes characters used in html to their equivalents, for example: < to > $query = mysql_real_escape_string($query); // makes sure nobody uses SQL injection $raw_results = mysql_query("SELECT * FROM classes WHERE (`ClassName` LIKE '%".$query."%') OR (`ClassInformation` LIKE '%".$query."%')") or die(mysql_error()); // * means that it selects all fields, you can also write: `id`, `title`, `text` // articles is the name of our table // '%$query%' is what we're looking for, % means anything, for example if $query is Hello // it will match "hello", "Hello man", "gogohello", if you want exact match use `title`='$query' // or if you want to match just full word so "gogohello" is out use '% $query %' ...OR ... '$query %' ... OR ... '% $query' if(mysql_num_rows($raw_results) > 0){ // if one or more rows are returned do following while($results = mysql_fetch_array($raw_results)){ // $results = mysql_fetch_array($raw_results) puts data from database into array, while it's valid it does the loop echo "<div id='results' style='background-image: url(bigresultbox.png); border: 1px solid black;'><h3>".$results['ClassName']."</h3>".$results['ClassInformation']."</div>"; // posts results gotten from database(title and text) you can also show id ($results['id']) } } else{ // if there is no matching rows do following echo "<div id='noresults'>No results</div>"; } } else{ // if query length is less than minimum echo "<div id='noresults' style='background-image: url(bigresultbox.png); border: 1px solid black;'> Minimum search length is $min_length characters</div>"; }
This is what my results page currently looks like displaying "ClassName" followed by "ClassInformation" for each query that matches results. If I insert a new table column to reference images what would be the best method of doing this to go along with each returned query as shown below?

Thanks everyone.