473,473 Members | 2,036 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

showing image from database

22 New Member
the issue I am having is when a client logs into the system we want all their info to show up (from the nocsis table) then match the last name to the image table. All is working well with my select statement the only problem is the image doesn't show up. I believe what is diplayed is MIME. How do I get the actually image to display. Thanks in advance


Expand|Select|Wrap|Line Numbers
  1. <?
  2. include_once('../sql_connect.php');
  3.  
  4.  
  5.  
  6.     $result = mysql_query("SELECT A.LastName, A.FirstName, A.Server, A.TimeIn, A.TimeOut, B.image  FROM nocsis A, image B WHERE A.LastName = B.LastName AND A.TimeOut IS NULL ORDER BY A.TimeIn ASC");
  7.  
  8.  
  9.  
  10.         while($myrow = mysql_fetch_array($result))
  11.  
  12.  
  13.  
  14.  
  15.              {//begin of loop
  16.  
  17.                //now print the results:
  18.  
  19.            echo "<b><u> Guest:</b></u> ";
  20.  
  21.                echo "<br>Last Name:&nbsp; &nbsp;";
  22.  
  23.                echo $myrow['LastName'];
  24.  
  25.                echo "<br>First Name:&nbsp; &nbsp;";
  26.  
  27.                echo $myrow['FirstName'];
  28.  
  29.            echo "<br>Image:&nbsp; &nbsp;";
  30.  
  31.            echo $myrow['image'];   
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.              }//end of loop
  42.  
  43.  
  44. ?>
  45.  
- posted this in the wrong area before, sorry
Feb 26 '08 #1
15 3532
ronverdonk
4,258 Recognized Expert Specialist
You will have to show the content of image, like this[php]echo "<img src =\"" . $myrow['image']."\">"; [/php]Ronald
Feb 26 '08 #2
matthewroth
22 New Member
You will have to show the content of image, like this[php]echo "<img src =\"" . $myrow['image']."\">"; [/php]Ronald

thanks, when i add that line i get the 'X' like the link is gone and then the mime result again, has to be something i am missing???
Feb 26 '08 #3
ronverdonk
4,258 Recognized Expert Specialist
thanks, when i add that line i get the 'X' like the link is gone and then the mime result again, has to be something i am missing???
Another way is[php]$image = $myrow['image'];
header("Content-type: image/jpeg");
print $image;[/php]Ronald
Feb 26 '08 #4
matthewroth
22 New Member
Another way is[php]$image = $myrow['image'];
header("Content-type: image/jpeg");
print $image;[/php]Ronald

your first way actually worked after i set the image as a link in mysql image field instead of the actual file. think i will leave it like that. Thanks alot.

how about another issue on this subject. how would i get a default image to show up if the person signing is not in my database
Feb 27 '08 #5
ronverdonk
4,258 Recognized Expert Specialist
I'll put it inside the total code in the ELSE branch:[php]
<?php
include_once('../sql_connect.php');
$result = mysql_query("SELECT A.LastName, A.FirstName, A.Server, A.TimeIn, A.TimeOut, B.image FROM nocsis A, image B WHERE A.LastName = B.LastName AND A.TimeOut IS NULL ORDER BY A.TimeIn ASC");
if (mysql_num_rows($result) > 0) {
while($myrow = mysql_fetch_array($result)) {//begin of loop
//now print the results:
echo "<b><u> Guest:</b></u> ";
echo "<br>Last Name:&nbsp; &nbsp;";
echo $myrow['LastName'];
echo "<br>First Name:&nbsp; &nbsp;";
echo $myrow['FirstName'];
echo "<br>Image:&nbsp; &nbsp;";
echo "<img src =\"" . $myrow['image']."\">";
} //end of loop
} // End IF
else {
echo "<img src ='default.jpg'>";
}
?>
[/php]Ronald
Feb 27 '08 #6
matthewroth
22 New Member
I'll put it inside the total code in the ELSE branch:[php]
<?php
include_once('../sql_connect.php');
$result = mysql_query("SELECT A.LastName, A.FirstName, A.Server, A.TimeIn, A.TimeOut, B.image FROM nocsis A, image B WHERE A.LastName = B.LastName AND A.TimeOut IS NULL ORDER BY A.TimeIn ASC");
if (mysql_num_rows($result) > 0) {
while($myrow = mysql_fetch_array($result)) {//begin of loop
//now print the results:
echo "<b><u> Guest:</b></u> ";
echo "<br>Last Name:&nbsp; &nbsp;";
echo $myrow['LastName'];
echo "<br>First Name:&nbsp; &nbsp;";
echo $myrow['FirstName'];
echo "<br>Image:&nbsp; &nbsp;";
echo "<img src =\"" . $myrow['image']."\">";
} //end of loop
} // End IF
else {
echo "<img src ='default.jpg'>";
}
?>
[/php]Ronald

You have been a great help. appreciate it

hmmm kinda works just no image (i did add a default image) is displayed when the LastName does not match in the table.

also if you're in the mood how would i get the images to show up next to each other rather than in a column
Feb 27 '08 #7
Markus
6,050 Recognized Expert Expert

also if you're in the mood how would i get the images to show up next to each other rather than in a column
You might want to check this thread for a neat little work around!
Feb 27 '08 #8
ronverdonk
4,258 Recognized Expert Specialist
Yes, that is a neat piece of code. I couldn't do it better! Justr replace the url's with the images and their text.

Ronald
Feb 27 '08 #9
matthewroth
22 New Member
You have been a great help. appreciate it

hmmm kinda works just no image (i did add a default image) is displayed when the LastName does not match in the table.

also if you're in the mood how would i get the images to show up next to each other rather than in a column

in the if statement would there be a way to state that if lastname not in table nocsis to display a default image
Feb 27 '08 #10
ronverdonk
4,258 Recognized Expert Specialist
in the if statement would there be a way to state that if lastname not in table nocsis to display a default image
But that is already in the code, you just have to replace the image name with the path/name of the one you want to display.[php] else {
echo "<img src ='your_image_name'>";[/php]Ronald
Feb 27 '08 #11
matthewroth
22 New Member
But that is already in the code, you just have to replace the image name with the path/name of the one you want to display.[php] else {
echo "<img src ='your_image_name'>";[/php]Ronald

the problem with that is it is searching for a 0 result. when someone signs in whether they have an image or not they still get logged in thus the result not being 0. only time the image appears is when no one is signed in.
Feb 27 '08 #12
ronverdonk
4,258 Recognized Expert Specialist
So in the ELSE branch you need this statement:
Expand|Select|Wrap|Line Numbers
  1. "SELECT A.LastName, A.FirstName, A.Server, A.TimeIn, A.TimeOut, FROM nocsis A WHERE A.TimeOut IS NULL ORDER BY A.TimeIn ASC");
Ronald
Feb 27 '08 #13
matthewroth
22 New Member
So in the ELSE branch you need this statement:
Expand|Select|Wrap|Line Numbers
  1. "SELECT A.LastName, A.FirstName, A.Server, A.TimeIn, A.TimeOut, FROM nocsis A WHERE A.TimeOut IS NULL ORDER BY A.TimeIn ASC");
Ronald
wouldnt the select statement need to compare the 2 tables somehow and select the LastName in one and not the other
Feb 27 '08 #14
ronverdonk
4,258 Recognized Expert Specialist
I don't know from which of the two tables you select or what table indicates that he has an image I just wanted to point out that you had to do a new select in case the result of the first select was 0.

Ronald
Feb 27 '08 #15
matthewroth
22 New Member
I don't know from which of the two tables you select or what table indicates that he has an image I just wanted to point out that you had to do a new select in case the result of the first select was 0. .

Ronald
Think I am on the right track. my query works with mysql when i do the else select i get the user that does not have a picture, i just cant seem to figure out how to display it or could it be that my if statement is jacked up. this code is got me going in circles. i didnt think it would be that hard to say if user signs in this table1 and has photo in this table2 display picture from table2 else if user signs in table1 and has no image in table2 show default image. any ideas??

Expand|Select|Wrap|Line Numbers
  1. <?
  2. include_once('../sql_connect.php');
  3.     $result = mysql_query("SELECT A.LastName, A.TimeOut, B.image, B.LastName  FROM nocsis A, image B WHERE A.LastName = B.LastName AND A.TimeOut IS NULL ORDER BY A.TimeIn DESC");
  4.  
  5.   if (mysql_num_rows($result) <> B.LastName ) {           
  6.  
  7.  
  8.  
  9. {//begin of loop
  10.  
  11.                //now print the results:
  12.  
  13.  
  14.  
  15.            echo '<table>'; // start the table.
  16.  
  17.  
  18.  
  19. $_counter = -1;  // We start 'outside' the Matrix.  Unlike Neo.
  20. $_cols = 4; // 4 columns.  Of the Ionic variety.
  21. while($myrow = mysql_fetch_array($result)){ //get array of table.
  22.  
  23.     // Advance the counter and determine our 'position';
  24.  
  25. $_pos = ( ++$_counter % $_cols );
  26.  
  27.     // Should we output a '<tr>'?
  28.  
  29. if( $_pos === 0 )
  30.     {
  31.         echo '<tr>';
  32.     }
  33.  
  34.  
  35. /// This will create link on picture to search for user on inside.spherion.com ////
  36. /// Still working on how to simply put 5-2 and pull image from inside.spherion.com at the myrow[image] call ////
  37.  
  38. echo "
  39. <td>
  40. <a href=\"http://inside.spherion.com/Search.aspx?k={$myrow['LastName']}&s=Search%20People\" target=\"_blank\">
  41. <img src=\"" . $myrow['image']."\" /></a>
  42. <b><br>Last Name:</b>
  43. {$myrow['LastName']}
  44.  
  45.  </td>"; // echoing out the image   
  46.  
  47.  
  48. // Should we output a '</tr>'?
  49.     if( $_pos === $_cols - 1 )
  50.     {
  51.         echo '</tr>';
  52.     }
  53. }
  54. if( $_counter % $_cols !== $_cols - 1 )
  55. {
  56.     do
  57.     {
  58.         echo '<td style="visibility: hidden">&nbsp;</td>';
  59.     }
  60.     while( ++$_counter % $_cols !== $_cols - 1 );
  61.  
  62.     echo '</tr>';
  63. }
  64.  
  65. echo '
  66. </table>';
  67. } //end of loop
  68.  
  69.  
  70. } // End IF
  71.  else {
  72. ("SELECT LastName FROM nocsis WHERE LastName NOT IN (Select LastName FROM image) AND TimeOut IS NULL ORDER BY TimeIn DESC");
  73.  
  74.  
  75.  }
  76.  
  77.  
  78.  
  79. ?>
  80.  
Feb 28 '08 #16

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

Similar topics

3
by: Dirk Goossens | last post by:
Hi! I stored the file name and path of photos in a table with data from students and teachers. Is there a way to show the photos in a report or form? Thanks! Dirk Goossens Vrij Instituut...
10
by: bessington | last post by:
hey all, i'm having a rather bizarre problem.. the image tag i have declared in my xhtml is not showing in safari / konqueror but showing just fine in Firefox, IE, Opera... this is a complete...
7
by: needin4mation | last post by:
Hi, I have an Access 2002 - 2003 database. I am using Access 2003. Whenever I link an image all it shows is the filename. Not the image. Other versions of Access can link the image just fine. ...
8
by: Gabriella | last post by:
Hi, I have the CSS class below, and the image (pro.gif) is not showing on my page. It is showing ONLY where's some text in the div, but all I need is the image itself. ..pro {background-image:...
3
by: Sandeep Singh Sekhon | last post by:
I am developing an application in ASP.NET 1.1. on one page I allow the user to upload and delete the files to the server. When I delete the file, I physically delete the file from the location....
0
by: Milsnips | last post by:
hi there, i've a function that reads image filenames from database, and displays into a repeater control, but what i'm trying to acheive is as i loop through each filename, i want to resize it...
0
by: Iain | last post by:
Hi I am using Borland Developer 2006, C# web application. Fairly new to the .net platform and very new to repeaters. I have 2 repeaters on a page, both of which are filled from a database....
6
by: painkiller | last post by:
language: vb.net environment: windows forms .net : v1.1 i am having a checkedlistbox control that display document category such as text, image, video, audio etc. these values are coming from...
1
mikek12004
by: mikek12004 | last post by:
I am using this code to produce an xml file, do not pay any attetion to the queries the thing is that even if I put the UTF-8 encoding when I try to run the xml file I get the greek characters as...
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...
1
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
bsmnconsultancy
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...

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.