hi,
in the below code i have made a variable $htmll, in my php file.In dat var i have stored the html code,in dat html code im writing some php code which in unable to execute....Kindly help me out to resolve it.
Thanx....

<?php
 $htmll='
 <table align="centre" border="1" cellpadding="0" cellspacing="0" bgcolor="#E3EEB7" style="font-size:10px; font-faimly:vardana;">
  <tr>
    <td width="19" bgcolor="#B7C6B0">Inp</td>
    <td width="19" bgcolor="#B7C6B0">Pre</td>
    <td width="24" bgcolor="#B7C6B0">Lea </td>
    <td width="21" bgcolor="#B7C6B0">Abs</td>
    <td width="34" bgcolor="#B7C6B0">%Age</td>
    
  </tr>'.
  while($attnobj=@mysql_fetch_object($result))//this while is not working.im getting the parser error.
  {
		$off17_inp	=	$attnobj->off17_inp;
		$off17_pre	=	$attnobj->off17_pre;
		$off17_lea	=	$attnobj->off17_lea;
		$off17_abs	=	$attnobj->off17_abs;
		
		.'
  
  <tr>
    <td>&nbsp;</td>
    <td>'.$ftysecname.'</td>
    <td>'.$off17_inp.'</td>
    <td>'.$off17_pre.'</td>
    <td>'.$off17_lea.'</td>
    <td>'.$off17_abs.'</td>
    
  </tr> '.}.'
  
</table>';
?>
Member Avatar for rajarajan2017

check whether you got the $result by echo the part. and mention the parse error what you get?

Parse error: parse error in C:\wamp\www\attendance\report.php on line 12
there is no echo part in $result

Member Avatar for rajarajan2017

Thats why I want you to check that. you used $result in while loop, insert a statement before while loop

echo $result;

Parse error: parse error in C:\wamp\www\attendance\report.php on line 12
there is no echo part in $result

actually its like this
$result = $attendanceDAO->getreportattendance($date,$shift);
// i have call it above the varable $htmll
i have echoed the $result and im geting the values if i use while out of $htmll but getting parser error if i use while inside the $htmll

Member Avatar for diafol

You are concatenating string - loop - string.
Place this before the html variable:

//do your DB object here
$trows="";
while($attnobj=@mysql_fetch_object($result)){
		$off17_inp	=	$attnobj->off17_inp;
		$off17_pre	=	$attnobj->off17_pre;
		$off17_lea	=	$attnobj->off17_lea;
		$off17_abs	=	$attnobj->off17_abs;
 
$trows .= "<tr>
    <td>&nbsp;</td>
    <td>$ftysecname</td>
    <td>$off17_inp</td>
    <td>$off17_pre</td>
    <td>$off17_lea</td>
    <td>$off17_abs</td>
 
  </tr>";
}

$htmll='
 <table align="centre" border="1" cellpadding="0" cellspacing="0" bgcolor="#E3EEB7" style="font-size:10px; font-faimly:vardana;">
  <tr>
    <td width="19" bgcolor="#B7C6B0">Inp</td>
    <td width="19" bgcolor="#B7C6B0">Pre</td>
    <td width="24" bgcolor="#B7C6B0">Lea </td>
    <td width="21" bgcolor="#B7C6B0">Abs</td>
    <td width="34" bgcolor="#B7C6B0">%Age</td>
 
  </tr>' . $trows . '</table>';

BTW: formatting your html in php woun't beautify your html. You can use heredoc or \n and \t to do this.

thanku so much
well i know it woudn beautify ma html but its the requirment ov ma code
anyay thnx fo ya help:)

Member Avatar for diafol

If this is solved, mark it solved. Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.