Jump to content

how to get the image from the folder


dark k58

Recommended Posts

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

Link to comment
Share on other sites

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";

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.