Jump to content

a php inside php


popodc

Recommended Posts

      [color=red]<?php[/color]
if (!$excel) {
echo '<tr valign="top">
                <td height="25" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="1" cellpadding="0">
              <tr>
                <td width="113" valign="middle" bgcolor="#999999"><p><font color="#000000" face="Tahoma"><strong>Employee
                    No:</strong></font></p></td>
                <td width="257" valign="top" bgcolor="#CCCCCC"> <table width="100%" height="19" border="0" cellpadding="0" cellspacing="1">
                    <tr>
                      <td bgcolor="#FFFFFF"><p><strong><font color="#000000" face="Tahoma">
                          [color=red][b]<?php echo $empid; ?>[/b][/color] </font></strong></p></td>
                    </tr>
                  </table>';
}
[color=red]?>[/color]

id like to know if its possible to have a php code inside a php.. if not, how do i do this highlightext text? thanks!
Link to comment
Share on other sites

[code]echo '<td>' . $empid . '</td>';[/code]

For example.. in your case, replace the <?php echo $empid; ?> with this:

[code]' . $empid . '[/code]

The dot means "stick two strings together".  So you are sticking the first half of the string, $empid and the last part of the string together into one big string.  That big string is then echoed.
Link to comment
Share on other sites

Or...

[code]<?php

  if (!$excel) {

  echo"
  <tr valign=\"top\">
  <td height=\"25\" bgcolor=\"#FFFFFF\"><table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\">
  <tr><td width=\"113\" valign=\"middle\" bgcolor=\"#999999\"><p><font color=\"#000000\" face=\"Tahoma\"><strong>Employee
  No:</strong></font></p></td>
  <td width=\"257\" valign=\"top\" bgcolor=\"#CCCCCC\"> <table width=\"100%\" height=\"19\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\">
  <tr><td bgcolor=\"#FFFFFF\"><p><strong><font color=\"#000000\" face=\"Tahoma\">$empid</font></strong></p></td></tr>
  </table>";

?>[/code]
Link to comment
Share on other sites

i would suggest using echo <<<html
it is much more easier. example:
[code=php:0]
      <?php
      if (!$excel) {
echo <<<html
<tr valign="top">
                <td height="25" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="1" cellpadding="0">
              <tr>
                <td width="113" valign="middle" bgcolor="#999999"><p><font color="#000000" face="Tahoma"><strong>Employee
                    No:</strong></font></p></td>
                <td width="257" valign="top" bgcolor="#CCCCCC"> <table width="100%" height="19" border="0" cellpadding="0" cellspacing="1">
                    <tr>
                      <td bgcolor="#FFFFFF"><p><strong><font color="#000000" face="Tahoma">{$empid}</font></strong></p></td>
                    </tr>
                  </table>
html;
}
?>
[/code]
Link to comment
Share on other sites

[quote author=btherl link=topic=114345.msg465206#msg465206 date=1163033996]
[code]echo '<td>' . $empid . '</td>';[/code]

For example.. in your case, replace the <?php echo $empid; ?> with this:

[code]' . $empid . '[/code]The word you seek is Concatenate :)

The dot means "stick two strings together".  So you are sticking the first half of the string, $empid and the last part of the string together into one big string.  That big string is then echoed.
[/quote]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.