DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   PHP (http://www.daniweb.com/forums/forum17.html)
-   -   PHP code not blending with HTML (http://www.daniweb.com/forums/thread13583.html)

qazs Nov 6th, 2004 8:03 am
PHP code not blending with HTML
 
Hi,
I'm trying to create some rows in a table using php code.
Its like this:
<table border="1" cellspacing="0" cellpadding="0">
  <tr>
    <td width>some item</td>
  </tr>
  <?php
  echo drawRow(); // draw another similar row
  ?>
</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.

fpepito Nov 6th, 2004 8:31 am
Re: PHP code not blending with HTML
 
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

billah_norm Nov 7th, 2004 5:12 pm
Re: PHP code not blending with HTML
 
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.

qazs Nov 9th, 2004 10:11 am
Re: PHP code not blending with HTML
 
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.


All times are GMT -4. The time now is 2:22 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC