954,168 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

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.

qazs
Newbie Poster
7 posts since Oct 2004
Reputation Points: 10
Solved Threads: 0
 

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

fpepito
Newbie Poster
14 posts since Oct 2004
Reputation Points: 10
Solved Threads: 1
 

Your code should look like this......

[PHP]
some item

<?php
drawRow(); // draw another similar row
?>

<?php //Your drawRow function should look like this
function drawRow(){
echo "Your Code Here";
}
?>
[/PHP]

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

Calling a function without echo works fine.

THANKS.

billah_norm
Light Poster
25 posts since Sep 2004
Reputation Points: 10
Solved Threads: 0
 

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.

qazs
Newbie Poster
7 posts since Oct 2004
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You