hie everyone…
i want to display images on word document thru php coding… i have successfully generated the word document evn it is displaying all other data from database except images…it is showing the path on word page instead of image…
whats the problem…i have used the same path of images in other applications to display images…
Please can you post the source code for the PHP file that creates the document?
header(“Content-type: application/vnd.ms-word”);
header(“Content-Disposition: attachment;Filename=shortlisedpics.doc”);
add this in the end part of yr code…
Use HTML image tags:
[php][/php]
i tried this already…bt it is displaying a cross mark instead of image
Have you got the image uploaded on your site and are you using a publicly accessible, full URL?
e.g:
http//www.some-site.com/image.jpg
Rather than:
/image.jpg
there is no such url for my image…query get executed for showing images one by one…thats m giving only path for images
What do you mean? Could you post what format the image src is in?
this is part of my code…i did it as you suggest and the image whose path i specified displayed properly also…but the thing is how yo display all photos as m using for loop…cz it is not related to one image…here is my part of the code…pls do needful…its very urgent
[php]while ($row=mysql_fetch_array($result))
{$regid=$row[0];
$blow=$row[1];
if($regid)
{
$objectIndex = “PHT”;
$whereclause = " WHERE RegID=".$regid;
$otherclause = “”;
$fields = “PhotoID, BlowUp, DisplayType, RegID”;
//$result_array = _getRows($objectIndex, $fields, $whereclause, $otherclause);
$result_array="select ".$fields. "from" .$objectIndex."where" .$whereclause;
$blowup_indx = 1;
$regid_indx = 3;
for($i=0;$i<count($result_array);$i++)
{
$photo="<img src='" . _getBaseUrl() . "/photographs/" . $result_array[$i][$blowup_indx] . "' border=1 width=100 height=100>";
$str.="<tr><td>$regid</td><td>$photo</td></tr>";
}}}[/php]
At a glance, that code looks fine to me. Could you temporarily remove the word document header part and send the output that your script generates?
it is displaying the same output on webpage but on word document it was showing cross mark instead of image…n on web page it is just creating a box of specified height and width bt nt showing image
my path is ryt as i have used the same in many other applications
Unless some sort of anti-hotlinking or other website copying protection is preventing the server from displaying the images, something must be wrong with the paths.
Can you post back with the view-source of that page?
this is the source code of output page…
RegID | Photo |
15039 | |
15039 | |
15027 | |
15027 |
have any other solution???
jSherz pls give me some solution…m fed up now…
Your image src’s are not being correctly generated. For example:
../photographs/$result_array[$i][$blowup_indx]
This is not right. For some reason, PHP is outputting the variable name ($result_array[$i][$blowup_indx]) and not the contents of that variable.
From the look of:
[php]$objectIndex = “PHT”;
$whereclause = " WHERE RegID=".$regid;
$otherclause = “”;
$fields = “PhotoID, BlowUp, DisplayType, RegID”;
//$result_array = _getRows($objectIndex, $fields, $whereclause, $otherclause);
$result_array="select ".$fields. “from” .$objectIndex.“where” .$whereclause;
$blowup_indx = 1;
$regid_indx = 3;[/php]
Your query is not being correctly put together. You are also just putting the query string itself into the variable $result_array. If you perform a MySQL query, you must first execute it with the mysql_query function and then get the results from it, for example with mysql_fetch_array.
Have you tried commenting the second $result_array:
[php]$result_array="select ".$fields. “from” .$objectIndex.“where” .$whereclause;[/php]
And then uncommenting:
[php]//$result_array = _getRows($objectIndex, $fields, $whereclause, $otherclause);[/php]
It appears that the _getRows function that you have should do what you are trying to achieve.
by doing this,only column names are displayed i.e. regid and pfoto…
nt extracting any other info
i worked on it n m getting output as
15039 …/photographs/
15039 …/photographs/
15027 …/photographs/
15027 …/photographs/
it means that it is not extracting image id now…i.e. result_array[$i][$blowup_indx]
hwy prob is solved now…thank u so much…this is the code
[php]<?php mysql_connect (“localhost”,“peter”,“123”);
mysql_select_db(“inmatch”);
//error_reporting( E_ALL );
$requestid=$_GET[‘requestid’];
$clientid=$_GET[‘clientid’];
function _getRows($objectIndex, $fields, $whereclause)
{
$sqlquery = "select " . $fields . " from " . $objectIndex . " " . $whereclause ;
$result_array=mysql_query($sqlquery);
return $result_array;
}
$query="select RM.RegID,P.Blowup from shortlist MT, registration_male RM,photo P WHERE MT.RequestID='$requestid' AND MT.ClientId=$clientid AND MT.RegID=RM.RegID AND P.RegID=RM.RegID ";
$result=mysql_query($query);
$str="<table width='50%' border='1' align='center'><tr><td>RegID</td><td>Photo</td></tr>";
$blowup_indx = 1;
while ($row=mysql_fetch_array($result))
{
$regid=$row[0];
$objectIndex = "PHT";
$whereclause = " WHERE RegID=".$regid;
$otherclause = "";
$fields = "PhotoID, BlowUp, DisplayType, RegID";
$result_array1= _getRows($objectIndex, $fields, $whereclause);
$photo="";
if($regid)
{
for($i=0;$i<count($result_array1);$i++)
{
$str.="<tr><td>$regid</td><td>$photo</td></tr>";
}
}
}
$str.="</table>";
header("Content-type: application/vnd.ms-word");
header("Content-Disposition: attachment;Filename=shortlisted.doc");
echo $str;
exit;
?>[/php]
big problemmmmmmmmmmm
in that doc file,only image is not visible to receiptant…i m nt getting y this is happening now…
pls work on this prb