473,714 Members | 1,993 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to display image from mysql

34 New Member
i am doing a site for spinning mills
i need to display all the products that the company offers
Am using mysql database and word press (CMS)

i want to display my images with code number as like my attachment
Attached Images
File Type: jpg shade.jpg (11.9 KB, 609 views)
Mar 9 '10 #1
19 9290
5,058 Recognized Expert Expert

What have you done so far?
And what are you having trouble with?
Mar 9 '10 #2
34 New Member
i want to display my images with that code. and also i want upload tat scanned images in our database.that time i want group that image color vise.
Mar 9 '10 #3
34 New Member
Am doing that manual not writing any queries
Mar 9 '10 #4
5,058 Recognized Expert Expert
Ok. What have you done so far?

I don't know much about the specifics of WordPress, but I do know that in plain PHP this should be a simple matter of querying the data from the database, looping through the results and printing each one.

What do you mean? If you plan on interacting with a MySQL database, you will have to write a few queries.
Mar 9 '10 #5
34 New Member
Expand|Select|Wrap|Line Numbers
  1. <?
  2. $dbcnx = @mysql_connect("localhost", "root", "red");
  4. if (!$dbcnx)
  5. {
  6. echo( "connection to database server failed!" );
  7. exit();
  8. }
  10. if (! @mysql_select_db("my_db") )
  11. {
  12. echo( "Image Database Not Available!" );
  13. exit();
  14. }
  16. $img = $_REQUEST["img"];
  17. $result = @mysql_query("SELECT * FROM images WHERE imgid=" . $img . "");
  19. if (!$result)
  20. {
  21. echo("Error performing query: " . mysql_error() . "");
  22. exit();
  23. }
  25. while ( $row = mysql_fetch_array($result) )
  26. {
  27. $imgid = $row["imgid"];
  28. }
  30. echo base64_decode($encodeddata);
  31. ?>

this is not work what problem in that
Mar 9 '10 #6
5,058 Recognized Expert Expert
I'm not surprised, seeing as this code was copy/pasted from an online tutorial (yes I can use Google too), one that was not meant to be put as-is into a working product. - It's meant to teach, not to be used.

You won't get a working solution by copy/paste alone. You need to actually know, or learn, PHP and MySQL to get this working. - And we will most certainly not be doing it for you.

If you want our help, tell us specifically what you are having trouble with. We aren't just going to take code you copied from some random tutorial and fix it up so you can copy it back into your project.
Mar 9 '10 #7
34 New Member
dear Atli

Please help me. When we want to display our images from database that time we start our script like
<img src="filename.p hp?id="imageid" >
what is the use of this..
and where that image id will retrieve. I think that is our table id. is it correct or not.
Mar 10 '10 #8
5,058 Recognized Expert Expert
The "imageid" there is the ID of an image from your database, which the "filename.p hp" script takes and retrieves, returning it to the <img>
Mar 10 '10 #9
34 New Member
i cant store my image to database
please check the following code is correct or not because that code did not return any
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $connection=mysql_connect("localhost","root","mypassword");
  3. if(!$connection)
  4. {
  6. die('Not connect'.mysql_error());
  7. }
  8. // Create table
  9. mysql_select_db("my_db", $connection);
  10. $sql = "CREATE TABLE myimage
  11. (
  12. id int(5) NOT NULL auto_increment. ,
  13. image longblob NOT NULL,
  14. description char(50)
  15. )";
  16. mysql_query($sql,$connection);
  17. echo "table Created";
  18. mysql_select_db("my_db",$connection);
  20.     $imgdata = file_get_contents($_FILES['fimage']['tmp_name']);
  21.     $fpo      = fopen($imgdata, 'r'); 
  22.     $imgdata1 = fread($fpo, filesize($imgdata));
  23.     $imgdata1 = mysql_real_escape_string($imgdata1 );
  25. $sql = "INSERT INTO myimage (image,description) VALUES 
  26. ('$_POST['fdescription']','$imgdata1')";
  27. if (!mysql_query($sql,$connection))
  28. {
  30.  die('Error'.mysql_error());
  31. }
  32. print ="Description;$fdescription";
  33. mysql_close($connection);
  34. ?>
Mar 10 '10 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

by: adam | last post by:
Hi, I have an issue that i just cant seem to figure out hope some one can help. right i am getting people to input the own images directly into a blob within a mysql database. then on the next page i want to display the image with in a nicely formatted html table so i can put the image where i choose on the page *this code is only putting the image on the top of the page and wont let me output any other text etc*
by: Dan Anderson | last post by:
I have created a BLOB field to store images. Is there any way to embed them within HTML with something like: <image start: jpeg> </image> Thanks in advance, Dan
by: david | last post by:
Hi, I have asp pages running from a MySQL database. I have placed a path in the required field (although not quite sure on the correct format). My asp page is just displaying the text path instead of the image. I'm using response.write. The Folder is called : images
by: davidgordon | last post by:
Hi, I have a form in which I need to display an image of our product. On our server is a folder which contains all the images. In our MySQL db to which our MS Access 2003 front end is linked, are paths to the specific image folder for each product. A variable carries over the required path of the image to the required form as:
by: Objectifnet | last post by:
What I really want to do is to be able to link two pages together using an ID, The table involved displays an image stored on the File Server that has the image details stored in the Database called. THE Database used is MySQL "Support" on a Table Called "profiles": The problem is how do I get this piece of codes to link to a details page called "PATRONS_DETAILS.PHP" and display information about one particular database detail. With ID...
by: eholz1 | last post by:
Hello Group, Perhaps you can help me. I have a mysql db, that holds images. Images are encoded using base64_decode/encode, etc. Image data seems fine. I have a view.php page that is supposed to show the image, and an image.php page that accesses the database, retrives the image data, and then (theoretically) prints the decoded data to the page. below is the view.php page code: problem area the img tag src no
by: tanyali | last post by:
my .png files r stored as a blob in MySql, I wanna to display them out in php through a web browser. this is part of code (in php): ---after connect to database , $dbQuery=" select name, png1, png2 from png"; $result=mysql_query($dbQuery) or die("Could not get file list"); // to display
by: alexseow | last post by:
Query.asp <%@ LANGUAGE="VBSCRIPT" %> <!-- #include file="../../includes/dbconn.asp"--> <% dim MyRs, sqlstr, MyConn Response.Expires = 0 Response.Buffer = TRUE Response.Clear
by: foss | last post by:
HI all, I am able to upload the image as blob to mysql. but while displaying the image i cant display it properly . The code used for uploading image to mysql inserts data into mysql table.The uploading code is: MYSQL_CONNECT("localhost","root",""); mysql_select_db("sample"); $data = addslashes(fread(fopen($form_data, "r"), filesize($form_data))); $result=MYSQL_QUERY("INSERT INTO...
by: msmjsuarez | last post by:
how can i display both image and other information in the web page using php? i'm using mysql database. I do displaying the image only but i want to display both other information from the database and the image from the database also in one web page... how can i do this? pls help..... thanks.
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.