Author Topic: display images on word document  (Read 659 times)

jSherz

  • Expert PHP Helper
  • Senior Member
  • *****
  • Posts: 409
  • Karma: +4/-0
    • View Profile
    • jSherz.com
Re: display images on word document
« Reply #15 on: January 06, 2012, 09:21:41 AM »
Your image src's are not being correctly generated. For example:

Code: [Select]
../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 Code: [Select]
$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;


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 Code: [Select]
$result_array="select ".$fields"from" .$objectIndex."where" .$whereclause;

And then uncommenting:

PHP Code: [Select]
//$result_array = _getRows($objectIndex, $fields, $whereclause, $otherclause);

It appears that the _getRows function that you have should do what you are trying to achieve.
Looking for PHP tutorials? View mine. Please use code or PHP tags in your posts.

prajakta

  • Regular Member
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: display images on word document
« Reply #16 on: January 10, 2012, 01:16:23 AM »
by doing this,only column names are displayed i.e. regid and pfoto...
nt extracting any other info

prajakta

  • Regular Member
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: display images on word document
« Reply #17 on: January 10, 2012, 01:59:48 AM »
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]

prajakta

  • Regular Member
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: display images on word document
« Reply #18 on: January 10, 2012, 06:23:46 AM »
hwy prob is solved now...thank u so much...this is the code

PHP Code: [Select]
<?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="<img src= http://190.158.0.2/site/modelling/photographs/$row[$blowup_indx] border=1 width=150 height=150>";
	


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;
?>
« Last Edit: January 11, 2012, 09:52:15 AM by jSherz »

prajakta

  • Regular Member
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: display images on word document
« Reply #19 on: January 11, 2012, 02:08:04 AM »
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

prajakta

  • Regular Member
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: display images on word document
« Reply #20 on: January 11, 2012, 03:02:31 AM »
if i convert this doc file into pdf using word to pdf converter..but if im using pdf header to generate pdf file directly instead of word file...it is not working....
i got the prob that y only image is not getting displayed...it is bcz image path is on local server..thats y its nt opening but the thing is that this image url is not on remote...means on main site photos r nt visible...
i hope u r getting the prb

jSherz

  • Expert PHP Helper
  • Senior Member
  • *****
  • Posts: 409
  • Karma: +4/-0
    • View Profile
    • jSherz.com
Re: display images on word document
« Reply #21 on: January 11, 2012, 09:51:57 AM »
If they're not on the main server, then you need to have them on there.
Looking for PHP tutorials? View mine. Please use code or PHP tags in your posts.

prajakta

  • Regular Member
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: display images on word document
« Reply #22 on: January 12, 2012, 01:11:00 AM »
no i cant do that...coz this is confidential data of company..so need to send to specific people only...thats the problem...
can u tell me one more thing....how can i zip all this data in zip folder???