Hướng dẫn display image php mysql
I have to display images on my php web page from mysql database where i have give the path of my images. but Its only displaying the path but not the image. I used the following Code:
and the output I am getting is : images/DSC01750.jpg Some body can you please help me to actually displaying the image but not the path. Many Thanks asked Nov 2, 2011 at 15:07
If you wish to display an image in an HTML page, you can construct the image tag like this:
If you are attempting to obscure the location of an image and serve it via the PHP script, your image tag will look something like this:
and you can modify your script to open and output the file:
answered Nov 2, 2011 at 15:09
George CumminsGeorge Cummins 27.9k8 gold badges67 silver badges90 bronze badges If
Note that "path" can mean something entirely different here. If it's a server-side fully qualified path, you'll want to translate it into an application-relative path usable by the browser. Something that begins with answered Nov 2, 2011 at 15:11
DavidDavid 194k34 gold badges191 silver badges268 bronze badges You need to wrap it in an img tag.
Bước 4: Tạo file connect.php để kết nối database Bước 5: Thêm file style.css #content{ margin: 20px auto; border: 1px solid #cbcbcb; overflow: auto; padding: 20px; } form{ margin: 20px auto; } form div{ margin-top: 5px; } #img_div{ padding: 5px; border: 1px solid #cbcbcb; float: left } #img_div:after{ content: ""; display: block; clear: both; } #img_div img{ float: left; margin: 5px; width: 400px; height: auto; } Sau khi tạo xong 4 file: thư mục photo trong máy tính, upload.php, xuly.php và connect.php, style.css bạn thử chạy vào xem kết quả như thế nào. Kết luận: Trên đây là code upload hình ảnh lên Database bằng PHP và MySQL, với bài hướng dẫn với các bước đơn giản trên hi vọng sẽ giúp bạn học thêm một chút kiến thức về lập trình PHP.
|