473,406 Members | 2,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to display the image within a div tag..?

this is my query.. where i need to display the result in a div... it shows the result in print $a perfectly.. but i needed the result to be within a div..?
Pls help me
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. header('Content-Type: image/jpg');
  3.  
  4. define('MYSQL_USER', '****');
  5. define('MYSQL_DB', 'upload');
  6. define('MYSQL_HOST', 'localhost');
  7. define('MYSQL_SERVER', 'localhost');
  8.  
  9. $con = mysql_connect(MYSQL_HOST,MYSQL_USER);
  10. if (!$con)
  11.   {
  12.   die('Could not connect: ' . mysql_error());
  13.   }
  14.  
  15. mysql_select_db(MYSQL_DB, $con);
  16.  
  17.      $query = 'SELECT *  FROM `file` order by id desc limit 1';
  18.  
  19.         // Execute the query
  20.       //  $result = $dbLink->query($query);
  21.         $result = mysql_query($query) or die(mysql_error());  
  22.     //$content='';
  23.         while($row = mysql_fetch_array( $result )) {
  24.             $a = $row['data'];        }    
  25.  
  26. //echo '<div style="width:200px; height:200px;">';
  27. sleep(2);
  28. print $a;
  29. //echo '</div>';
  30. //echo '<p><a href="test_image.php">Back to Main page</a></p>';
  31. ?>
  32. <html>
  33. <head>
  34. </head>
  35. <body>
  36.     <div></div>
  37. </body>
  38. </html>
Aug 21 '10 #1
5 4956
Thew
69
Just do this

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. </head>
  4. <body>
  5. <div>
  6. <?php echo $a; ?>
  7. </div>
  8. </body>
  9. </html>
  10.  
Thew
Aug 22 '10 #2
Atli
5,058 Expert 4TB
You can also put PHP variables into strings and then print the whole thing.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $name = "Atli";
  3. $str = "Hello, my name is $name";
  4.  
  5. echo $str; // Hello, my name is Atli
  6. ?>
Aug 22 '10 #3
Hi Thew.,

I tried that but it doesnt print the image...
what should i do now..
Pls help me
Aug 22 '10 #4
TheServant
1,168 Expert 1GB
Gunasegar, the code suggested by both Thew and Atli is basic PHP. When you say it does not print the image, do you mean it prints nothing, or something but not the image?

What does $a print normally?
Aug 23 '10 #5
i found the answer... thanks guys...
save this as test_view.php
<html>
<head>
<title>
</title>
</head>
<body>
<div>
<img src="test_viewer.php"/>
</div>
</body>
</html>
Aug 23 '10 #6

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

Similar topics

7
by: Philipp Lenssen | last post by:
I created Search.CSS which grabs Google results (using the Web API), displays as XHTML1.0 Strict + CSS, and recently also adds Thumbnails....
2
by: day | last post by:
I'm trying to use a non-scrolling background image within a div (the non-scrolling part is a "nice-to-have" vs a "have to have"). The style for that is: <div style="height=400px;...
0
by: Qindong Zhang | last post by:
My asp.net application send image to web browser. The browser begin to display image before download finished. (In Slow Network). How can I force brower to display image after the image downloaded? ...
1
by: Tan | last post by:
Hi I am desperate for any help with display image in Gridview I have a gridview contain surname , forename ..... and image. I could not display image as my database store the column image as...
2
by: David | last post by:
I am trying to get an image to appear on all Mondays within the calendar control. I also want that image to be a link. How can I do this?
3
by: den 2005 | last post by:
Hi everyone, Here is code working on..Trying to insert record with a column with Image or VarBinary datatype in sql database from a existing jpeg image file, then retrieve this image from...
1
by: Mike | last post by:
I'm using a SqlDataSource to fetch data and display it in a FormView. One of the elements is an image: <asp:Image ID="ImageFile" runat="server" ImageURL='<%# Eval("ImageFile",...
3
by: Ladislav Andel | last post by:
Hi, I'm trying to display image through my cgi script in HTML page via <img src="image.cgi"> Can you give me an example, please? What should be in the cgi script to display it? Here is what...
7
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
0
by: dbdb | last post by:
hi, i work with ms. access 2003 i want to display image from a folder to the report. i have read thread in http://bytes.com/topic/access/answers/191611-pictures-access-reports but that's...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
Oralloy
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,...
0
jinu1996
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...
0
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...

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.