team2005
asked on
Display pictures from database
Hi!
Have this page:
Its only looping ?
Have this page:
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
require_once('RAY_EE_config.php');
require_once('Connect_databse.php');
$table6 = 'ImageTable';
$sql = "SELECT * FROM {$table6}";
$resultraptmp = sqlsrv_query($conn,$sql);
?>
<table>
<?php
$sql = "SELECT * FROM {$table6}";
$rettmp = sqlsrv_query($conn,$sql);
if( $rettmp === false )
{
echo "Error in executing statement 7.\n";
die( print_r( sqlsrv_errors(), true));
}
$antbilder=0;
while($row3 = sqlsrv_fetch_array($rettmp)){
$antbilder= $antbilder+1;
}
?>
<?php
if($antbilder>0)
{
?>
<tr>
<?php
$sql = "SELECT * FROM {$table6}";
$rettmp2 = sqlsrv_query($conn,$sql);
$i=0;
$bilde[ ]=array();
while($row3 = sqlsrv_fetch_array($rettmp2)){
$bilde1 = "data:image/jpg;base64,";
$bilde2 = $row3['TransImage'];
$bilde[$i] = $bilde1 . $bilde2;
$i=$i+1;
?>
<?php } ?>
<?php
for($i=0;$i=$antbilder;$i++)
{ ?>
<td valign="top" class="rapport_image1">
<img src='<?php echo $bilde[$i] ?>' hight="190" align="left">
</td>
<?php }?>
<?php
if($antbilder>0)
{?></tr><?php }
} ?>
</table>
Its only looping ?
ASKER
Hi!
The customer dont want the images stored as files, and they want to stored
the pictures in a database.
Why cant i use my code ?
The customer dont want the images stored as files, and they want to stored
the pictures in a database.
Why cant i use my code ?
ASKER
Hi!
Sorry, my mistace...
I just have made this testfile, and forget to put in Header...
Sorry, my mistace...
I just have made this testfile, and forget to put in Header...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ray's Comments above are spot on. I would recommend visiting his links as well.
ASKER
Hi!
I just take out the code from a bigger file (about 800 lines of code)
But see that i missed out header++
Here is the modified file with header..
So please explane what is so wrong with this code.
Thanks
I have many 1000 hours of coding, but not an expert
I just take out the code from a bigger file (about 800 lines of code)
But see that i missed out header++
Here is the modified file with header..
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
require_once('RAY_EE_config.php');
require_once('Connect_databse.php');
$table6 = 'ImageTable';
$sql = "SELECT * FROM {$table6}";
$resultraptmp = sqlsrv_query($conn,$sql);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Agrippa report system 2</title>
<link href="css/redmond/jquery-ui-1.8.13.custom.css" rel="stylesheet" />
<script src='js/jquery.min.js' type='text/javascript'></script>
</head>
<body>
<table>
<?php
$sql = "SELECT * FROM {$table6}";
$rettmp = sqlsrv_query($conn,$sql);
if( $rettmp === false )
{
echo "Error in executing statement 7.\n";
die( print_r( sqlsrv_errors(), true));
}
$antbilder=0;
while($row3 = sqlsrv_fetch_array($rettmp)){
$antbilder= $antbilder+1;
}
?>
<?php
if($antbilder>0)
{
?>
<tr>
<?php
$sql = "SELECT * FROM {$table6}";
$rettmp2 = sqlsrv_query($conn,$sql);
$i=0;
$bilde[ ]=array();
while($row3 = sqlsrv_fetch_array($rettmp2)){
$bilde1 = "data:image/jpg;base64,";
$bilde2 = $row3['TransImage'];
$bilde[$i] = $bilde1 . $bilde2;
$i=$i+1;
?>
<?php } ?>
<?php
for($i=0;$i=$antbilder;$i++)
{ ?>
<td valign="top" class="rapport_image1">
<img src='<?php echo $bilde[$i] ?>' hight="190" align="left">
</td>
<?php }?>
<?php
if($antbilder>0)
{?></tr><?php }
} ?>
</table>
</body>
</html>
So please explane what is so wrong with this code.
Thanks
I have many 1000 hours of coding, but not an expert
ASKER
thanks
Then you can generate HTML <img> tags.
Note that the header() must come first and be complete before any browser output whatsoever, even including invisible whitespace. The HTML <table> statement on line 14 makes it impossible to issue header().