CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Displaying images

Print topic Send  topic

Author Message
Mick_D

Posts: 4
Posted: 06/22/2008, 7:18 AM

Hi,

Just started using trial version of CCS, but having problems displaying images from a MySQL database in a Gallery listing. The text is picked up fine; however the image is not. I'm sure it's something obvious, but I can't seem to find any reference to such problems on the forum (there are some references to uploading). I have specified the control type as an image.

To be honest, I thought the Gallery would would automatically pick up an image, so surprised to have this problem.

Thanks.
View profile  Send private message
Mick_D

Posts: 4
Posted: 06/22/2008, 10:09 AM

Actually, even if I store an image url in the database as an alternative and have the images in a sub-folder I still get no images displayed. I've also tried the 'Store' project and the images don't display with that example either.

As I say, probably something very straightforward, but please enlighten me if you can.

Thanks.
View profile  Send private message
Gena

Posts: 591
Posted: 06/22/2008, 10:18 AM

it seems that you have "path" problem. Look at HTML of your generated page and check your image paths. Something wrong there.
_________________
Gena
View profile  Send private message
Mick_D

Posts: 4
Posted: 06/22/2008, 2:04 PM

Many thanks - yes that was the reason for the images not displaying from their url's, but doesn't explain why the images aren't picked up from the database - I think some kind of PHP conversion file is necessary? (from what I've gleaned from various discussions).
View profile  Send private message
Gena

Posts: 591
Posted: 06/22/2008, 2:25 PM

Quote Mick_D:
Many thanks - yes that was the reason for the images not displaying from their url's, but doesn't explain why the images aren't picked up from the database - I think some kind of PHP conversion file is necessary? (from what I've gleaned from various discussions).
Yes, you can't just get image field from DB and show it as image using CCS. You need make some trick...

And this is quite easy :-)

Put label {Image} on your page.
Put some hidden field like id_foto (which is your foto ID)
Put code in Image_BeforeShow event like:

  
$id_foto = $Component->id_foto->GetValue();  
$tag = '<img src="' . ServerURL . 'ShowImg.php?id_foto=' . $id_foto  .'" border="0" alt="image">';  
$Component->Image->SetValue($tag);  

After than you need to create a php file ShowImg.php... It consists from:

  
<?  
define("RelativePath", ".");  
define("PathToCurrentPage", "/");  
define("FileName", "ShowImg.php");  
include(RelativePath . "/Common.php");  
  
  $id_foto=CCGetParam("id_foto","");  
      
  $db = new clsDBConnectionMKsystem();  
  $mime = "image/pjpeg";  
  $foto = file_get_contents(ServerURL . 'images\1x1.gif'); //if no image then put blank  
    
  if ($id_foto){  
  	$SQL = "select mime, foto from foto where id_foto=" . $id_foto ;  
	  $db->query($SQL);  
  	$db->next_record();  
	  $mime = $db->f("mime");  
  	$foto = $db->f("foto");  
  }  
  $db->close();  
  
header("Content-Type:" . $mime );   
echo $foto;  
?>  

publish all and try...
_________________
Gena
View profile  Send private message
Gena

Posts: 591
Posted: 06/22/2008, 2:28 PM

also using this way (using php file as IMG source in HTML file) can even generate and put any Images you want...
_________________
Gena
View profile  Send private message
Gena

Posts: 591
Posted: 06/22/2008, 2:31 PM

if you visit our site at www.motleysoft.com you can see dynamic counter (left-bottom side), it counts visitors, generates image (using our own backgroung image and by putting on numbers).
_________________
Gena
View profile  Send private message
Mick_D

Posts: 4
Posted: 06/22/2008, 2:43 PM

That's exactly what I was looking for. Many thanks.

Michael
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.