[SOLVED] Mixing PHP and HTML Code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
KingFisher
Forum Newbie
Posts: 2
Joined: Wed Nov 10, 2004 5:50 am

Mixing PHP and HTML Code

Post by KingFisher »

Hi,

My first time here! I'm hoping someone can help me out - I'm losing my hair rapidily.

I'm trying to modify a php page which has the following section of code:

Code: Select all

if ( $Globalsї'extra3name'] != "" ) {
echo<<<PPPRINT
        <tr><td class="tddetails">&#123;$Globals&#1111;'extra3name']&#125;:&nbsp;<input type="text" value="$extra3" size="10" name="extra3" /></td>
        <td class="tddetails">
		<table width="0%" border="0" cellpadding="o" cellspacing="0">
<tr align="left" valign="middle">
  <td colspan="9" nowrap class="MenuTableHeader" scope="col">Select Colours </td>
  </tr>
<tr align="left" valign="middle">
	<td width="0" nowrap scope="col"><font class="small">Black</font></td>
    	<td width="0" nowrap scope="col"><font class="small">White</font></td>
	<td width="0" nowrap scope="col"><font class="small">Brown</font></td>
    <td width="0" nowrap scope="col"><font class="small">Grey</font></td>
    <td width="0" nowrap scope="col"><font class="small">Red</font></td>
    <td width="0" nowrap scope="col"><font class="small">Orange</font></td>
    <td width="0" nowrap scope="col"><font class="small">Green</font></td>
    <td width="0" nowrap scope="col"><font class="small">Blue</font></td>
    <td nowrap scope="col"><font class="small">Yellow</font></td>

  </tr>
  <tr align="center">
    <td>
<?php 
$mystring = 'abc'; 
$findme  = 'a'; 
$pos = strpos($mystring, $findme); 
?>
<input type="checkbox" name="Param&#1111;2]" value="A"
<?php 
// Note our use of ===.  Simply == would not work as expected 
// because the position of 'a' was the 0th (first) character. 
if ($pos === false) &#123; 
?>The string '<?php echo $findme ?>' was not found in the string '<?php echo $mystring ?>'"; 
<?php &#125; else &#123; ?> 
checked 
and exists at position <?php echo $pos ?>" 
<?php &#125; 

// We can search for the character, ignoring anything before the offset 
$newstring = 'abcdef abcdef'; 
$pos = strpos($newstring, 'a', 1); // $pos = 7, not 0 
?>
  </td>
    <td><input type="checkbox" name="Param&#1111;3]" value="B"</td>
    <td><input type="checkbox" name="Param&#1111;4]" value="C"</td>
    <td><input type="checkbox" name="Param&#1111;5]" value="D"></td>
    <td><input type="checkbox" name="Param&#1111;6]" value="E"></td>
      <td><input type="checkbox" name="Param&#1111;7]" value="F"></td>
      <td><input type="checkbox" name="Param&#1111;8]" value="G"></td>
      <td><input type="checkbox" name="Param&#1111;9]" value="H"></td>
      <td><input type="checkbox" name="Param&#1111;10]" id="colour" value="I"></td>
  </tr></table>
              <br>

              <br>
              <table width="0%"  border="0" cellpadding="o" cellspacing="0">
              <tr align="center">
                <td colspan="4" nowrap class="MenuTableHeader" scope="col">Select Characteristics </td>
                </tr>
              <tr align="center">
                <td nowrap scope="col"><font class="small">Crest</font></td>
                <td nowrap scope="col"><font class="small">Eyecomb</font></td>
                <td nowrap scope="col"><font class="small">Moustache</font></td>
                <td nowrap scope="col"><font class="small">Wingbar</font></td>
              </tr>
              <tr align="center" valign="bottom">
                <td nowrap><input type="checkbox" name="Param&#1111;11]" value="A"></td>
                <td nowrap><input type="checkbox" name="Param&#1111;12]" value="A"></td>
                <td nowrap><input type="checkbox" name="Param&#1111;13]" value="A"></td>
                <td nowrap><input type="checkbox" name="Param&#1111;14]" value="A"></td>
              </tr>
          </table>  
              <br>
              <table width="200" border="0">
                <tr>
                  <td colspan="7" class="MenuTableHeader">Select The Location </td>
                </tr>
                <tr>
                  <td>Tree</td>
                  <td>In Flight </td>
                  <td>Reed</td>
                  <td>Field</td>
                  <td>Fresh Water </td>
                  <td>Salt Water</td>
                  <td>Arid/ Barren </td>
                </tr>
                <tr>
                  <td><div align="center">
                      <input name="radiobutton" type="radio" value="radiobutton">
                  </div></td>
                  <td><div align="center">
                      <input name="radiobutton" type="radio" value="radiobutton">
                  </div></td>
                  <td><div align="center">
                      <input name="radiobutton" type="radio" value="radiobutton">
                  </div></td>
                  <td><div align="center">
                      <input name="radiobutton" type="radio" value="radiobutton">
                  </div></td>
                  <td><div align="center">
                      <input name="radiobutton" type="radio" value="radiobutton">
                  </div></td>
                  <td><div align="center">
                      <input name="radiobutton" type="radio" value="radiobutton">
                  </div></td>
                  <td><div align="center">
                      <input name="radiobutton" type="radio" value="radiobutton">
                  </div></td>
                </tr>
              </table></td></tr>            
PPPRINT;
&#125;
It's this section I'm really frustrated over:

Code: Select all

<?php 
$mystring = 'abc'; 
$findme  = 'a'; 
$pos = strpos($mystring, $findme); 
?>
<input type="checkbox" name="Param&#1111;2]" value="A"
<?php 
// Note our use of ===.  Simply == would not work as expected 
// because the position of 'a' was the 0th (first) character. 
if ($pos === false) &#123; 
?>The string '<?php echo $findme ?>' was not found in the string '<?php echo $mystring ?>'"; 
<?php &#125; else &#123; ?> 
checked 
and exists at position <?php echo $pos ?>" 
<?php &#125; 

// We can search for the character, ignoring anything before the offset 
$newstring = 'abcdef abcdef'; 
$pos = strpos($newstring, 'a', 1); // $pos = 7, not 0 
?>
It just won't check the checkbox if conditions are correct - I suspect it's to do with punctuation, but I've spent nearly a week on this with no sucess.

Any help/ advice is appreciated.

KingFisher
KingFisher
Forum Newbie
Posts: 2
Joined: Wed Nov 10, 2004 5:50 am

Post by KingFisher »

Hey!

I was able to fix it myself - how 'bout that :D

For anyone else who's interested - the short answer is that you can't do what I was trying to do!
To solve the problem it's necessary to call the php function outside the heredoc stuff (& define your results as a variable) & THEN use the variable as $variable in the heredoc.

Maybe it'll help someone else!!

KF
mikeb
Forum Commoner
Posts: 60
Joined: Tue Jul 08, 2003 4:37 pm
Location: Dublin, Ireland

Post by mikeb »

Lol! It's funny how sometimes writing down a problem can help solve it!
Post Reply