PHP code not blending with HTML

Reply

Join Date: Oct 2004
Posts: 7
Reputation: qazs is an unknown quantity at this point 
Solved Threads: 0
qazs qazs is offline Offline
Newbie Poster

PHP code not blending with HTML

 
0
  #1
Nov 6th, 2004
Hi,
I'm trying to create some rows in a table using php code.
Its like this:
  1. <table border="1" cellspacing="0" cellpadding="0">
  2. <tr>
  3. <td width>some item</td>
  4. </tr>
  5. <?php
  6. echo drawRow(); // draw another similar row
  7. ?>
  8. </table>

But it turns out that the row is drawn before the table. In other words, it
seems like the php code is executed before the HTML code.
So what should I do instead?
Any help is appreciated, thank you.
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 14
Reputation: fpepito is an unknown quantity at this point 
Solved Threads: 1
fpepito fpepito is offline Offline
Newbie Poster

Re: PHP code not blending with HTML

 
0
  #2
Nov 6th, 2004
Hi qazs,

Difficult to answer, nothing strange in this part of code.

Can you send the code of the function drawRow().
Or peharps just the result of this function.

fpepito
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 25
Reputation: billah_norm is an unknown quantity at this point 
Solved Threads: 0
billah_norm billah_norm is offline Offline
Light Poster

Re: PHP code not blending with HTML

 
0
  #3
Nov 7th, 2004
Your code should look like this......

[PHP]
<table border="1" cellspacing="0" cellpadding="0">
<tr>
<td width>some item</td>
</tr>
<?php
drawRow(); // draw another similar row
?>
</table>
<?php //Your drawRow function should look like this
function drawRow(){
echo "<tr><td>Your Code Here</td></tr>";
}
?>
[/PHP]

You might do wrong in your HTML coding.. perhaps it is in your <td> tag. You might do it as </td>(close column tag) before starting a column tag (<td>). check it out.

Calling a function without echo works fine.

THANKS.
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 7
Reputation: qazs is an unknown quantity at this point 
Solved Threads: 0
qazs qazs is offline Offline
Newbie Poster

Re: PHP code not blending with HTML

 
0
  #4
Nov 9th, 2004
Hey thanks for the replies.
I figured out whats wrong. The reason is I already executed the drawRow()
function in an earlier php code.
Then in the table, I echo the drawRow() function again.
Meaning I executed the drawRow() function 2 times in 2
separate php code.
I dont know why it will have this effect, but after deleting
the first one, i managed to output the content neatly into the table.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC