dark k58 Posted April 25, 2012 Share Posted April 25, 2012 ok I uploaded images in a folder in my directory and uploaded the image detail to mysql database, the image has the same name as the id so if the id = 1 the image will be named 1.jpg this code is made for a search bar, so i would have a search bar in a separate page which link to this all my product will be listed here and when someone searches for a product it will show them only the spesific product they searched for my problem is i can't get the image up the so please help me thank you this is the code: <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Store Admin Area</title> <link rel="stylesheet" href="../style/style.css" type="text/css" media="screen" /> </head> <body> <div align="center" id="wrapper"> <?php include_once("template_header_user_login.php");?> <div id="content"> <?php include "../storescripts/connect_to_mysql.php"; $term = $_POST['term']; $sql = mysql_query("select * from products where product_name like '%$term%' or price like '%$term%' or details like '%$term%' or category like '%$term%' or subcategory like '%$term%' or date_added like '%$term%'"); while ($row = mysql_fetch_array($sql)){ echo "<table>"; echo "<tr>"; echo "<td>"; echo 'ID: '.$row['id']; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td>" ; echo '<br/> Product Name: '.$row['product_name']; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td>"; echo '<br/> Price: £ '.$row['price']; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td>"; echo '<br/> Detail: '.$row['details']; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td>"; echo '<br/> Category: '.$row['category']; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td>"; echo '<br/> SubCategory: '.$row['subcategory']; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td>"; echo '<br/> Date Added: '.$row['date_added']; echo "</td>"; echo "</tr>"; echo '<br/><hr><br/>'; echo "</tr>"; echo "</table>"; } ?> </div> <?php include_once("template_footer_user_login.php");?> </div> </body> </html> this is the search bar code <form action="search.php" method="post"> Search: <input type="text" name="term" /><br /> <input type="submit" name="submit" value="Submit" /> </form> more detail: I want it to select the image with the same id as the product and import it I was able to do that while using php url, but i didn't know how to do it here please help thanks Quote Link to comment https://forums.phpfreaks.com/topic/261592-how-to-get-the-image-from-the-folder/ Share on other sites More sharing options...
dark k58 Posted April 25, 2012 Author Share Posted April 25, 2012 this is a link to the page I'm trying to make it will display all the data and I want it to display the image on the left http://www.abdulrablahson.com/storeuser/productsearch.php Quote Link to comment https://forums.phpfreaks.com/topic/261592-how-to-get-the-image-from-the-folder/#findComment-1340485 Share on other sites More sharing options...
Psycho Posted April 25, 2012 Share Posted April 25, 2012 You don't have anything in your code to display an image. I would assume your query is returning the ID, so you just need to add a line in the code that produces the output that looks something like this: echo "<img src='path/to/image/folder/{$row['id']}.jpg'>\n"; Quote Link to comment https://forums.phpfreaks.com/topic/261592-how-to-get-the-image-from-the-folder/#findComment-1340486 Share on other sites More sharing options...
dark k58 Posted April 25, 2012 Author Share Posted April 25, 2012 thankyou Quote Link to comment https://forums.phpfreaks.com/topic/261592-how-to-get-the-image-from-the-folder/#findComment-1340489 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.