Jump to content

How to placed php code inside escaped tables?


co.ador

Recommended Posts

I am trying to insert this bit of php code

 

 <?php
      $ratingData = Rating::OutputRating($platename);
      
      if (Error::HasErrors())
      {
        echo Error::ShowErrorMessages();
        Error::ClearErrors();
      }
      else
      {
        echo $ratingData;
      }
    ?>

 

Inside the escaped echoed tables below. THe php code above is placed inside the escaped tables below. But it is not parsing correctly.

 

echo '<table width="100%"  border="0" cellspacing="0" cellpadding="0" class="itemdetails">
<tr>
<td width="1100" height="350" bgcolor="#FFFFFF" class="tento">
<table class="cafe"><tr><td width="547">
<a href="#"><h3 align="justify" style="position:relative; height:5px; top: 10px;">',$row[2] ,'</h3></a>
</td>
</tr>
</table>
<table width="1215" height="609" class="chencho" >
<td class="largethumb" rowspan="8" align="center">
<a href="#"><img src="../images/image1.jpg" width="270" height="160" alt="coloe"/></a></td>
<td width="340" rowspan="8" padding="0"  ><table width="252" style="font-size:12px; position:relative; top:-6px;">
  <td width="1"> </td>
  <td width="54" bgcolor="#FFFFFF"><strong>Price:</strong></td>
  <td colspan="7">$<span class="style3">',$row[6] ,'</span></td>
<tr>
  <td class="style1"> </td>
  <td colspan="7" class="style3"> </td>
</tr>
<tr><td> </td><td><strong>Raiting:</strong></td>
  <td><table height"50" width="47%">        
<?php
      $ratingData = Rating::OutputRating($platename);
      
      if (Error::HasErrors())
      {
        echo Error::ShowErrorMessages();
        Error::ClearErrors();
      }
      else
      {
        echo $ratingData;
      }
    ?></table></td>
</tr>';

<?php
echo '<table width="100%"  border="0" cellspacing="0" cellpadding="0" class="itemdetails">
<tr>
<td width="1100" height="350" bgcolor="#FFFFFF" class="tento">
<table class="cafe"><tr><td width="547">
<a href="#"><h3 align="justify" style="position:relative; height:5px; top: 10px;">'.$row[2].'</h3></a>
</td>
</tr>
</table>
<table width="1215" height="609" class="chencho" >
<td class="largethumb" rowspan="8" align="center">
<a href="#"><img src="../images/image1.jpg" width="270" height="160" alt="coloe"/></a></td>
<td width="340" rowspan="8" padding="0"  ><table width="252" style="font-size:12px; position:relative; top:-6px;">
  <td width="1"> </td>
  <td width="54" bgcolor="#FFFFFF"><strong>Price:</strong></td>
  <td colspan="7">$<span class="style3">'.$row[6] .'</span></td>
<tr>
  <td class="style1"> </td>
  <td colspan="7" class="style3"> </td>
</tr>
<tr><td> </td><td><strong>Raiting:</strong></td>
  <td><table height"50" width="47%"> '.
      $ratingData = Rating::OutputRating($platename);
      
      if (Error::HasErrors())
      {
        echo Error::ShowErrorMessages();
        Error::ClearErrors();
      }
      else
      {
        echo $ratingData;
      }
.'</table></td>
</tr>';

now there is a parse error

 

Parse error: parse error in C:\wamp\www\shoes\stores\itemdetails2.php on line 192

 

<?php
echo '<table width="100%"  border="0" cellspacing="0" cellpadding="0" class="itemdetails">
<tr>
<td width="1100" height="350" bgcolor="#FFFFFF" class="tento">
<table class="cafe"><tr><td width="547">
<a href="#"><h3 align="justify" style="position:relative; height:5px; top: 10px;">'.$row[2].'</h3></a>
</td>
</tr>
</table>
<table width="1215" height="609" class="chencho" >
<td class="largethumb" rowspan="8" align="center">
<a href="#"><img src="../images/image1.jpg" width="270" height="160" alt="coloe"/></a></td>
<td width="340" rowspan="8" padding="0"  ><table width="252" style="font-size:12px; position:relative; top:-6px;">
  <td width="1"> </td>
  <td width="54" bgcolor="#FFFFFF"><strong>Price:</strong></td>
  <td colspan="7">$<span class="style3">'.$row[6] .'</span></td>
<tr>
  <td class="style1"> </td>
  <td colspan="7" class="style3"> </td>
</tr>
<tr><td> </td><td><strong>Raiting:</strong></td>
  <td><table height"50" width="47%"> '.
      $ratingData = Rating::OutputRating($platename);
      
      if (Error::HasErrors())
      {
        echo Error::ShowErrorMessages();
        Error::ClearErrors();
      }
      else
      {
        echo $ratingData;
      }.'  //This is line 192 where the browser has found the parsing error
</table></td>
</tr>';

That code doesn't work because php is only parsed once. The parsed page doesn't get looked at again. This should work:

<?php
echo '<table width="100%"  border="0" cellspacing="0" cellpadding="0" class="itemdetails">
<tr>
<td width="1100" height="350" bgcolor="#FFFFFF" class="tento">
<table class="cafe"><tr><td width="547">
<a href="#"><h3 align="justify" style="position:relative; height:5px; top: 10px;">',$row[2] ,'</h3></a>
</td>
</tr>
</table>
<table width="1215" height="609" class="chencho" >
<td class="largethumb" rowspan="8" align="center">
<a href="#"><img src="../images/image1.jpg" width="270" height="160" alt="coloe"/></a></td>
<td width="340" rowspan="8" padding="0"  ><table width="252" style="font-size:12px; position:relative; top:-6px;">
  <td width="1"> </td>
  <td width="54" bgcolor="#FFFFFF"><strong>Price:</strong></td>
  <td colspan="7">$<span class="style3">',$row[6] ,'</span></td>
<tr>
  <td class="style1"> </td>
  <td colspan="7" class="style3"> </td>
</tr>
<tr><td> </td><td><strong>Raiting:</strong></td>
  <td><table height"50" width="47%">';
      $ratingData = Rating::OutputRating($platename);
      
      if (Error::HasErrors())
      {
        echo Error::ShowErrorMessages();
        Error::ClearErrors();
      }
      else
      {
        echo $ratingData;
      }
      echo '</table></td>
</tr>';
?>

 

You have to end that echo, put the code in, then start another echo for the rest.

 

Oh and just one little thing, it's better not to use the <table>, <tr>, <td> etc. elements. You can use css to create tables. I think xhtml gets rid of those elements.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.