| | |
PHP code not blending with HTML
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Oct 2004
Posts: 7
Reputation:
Solved Threads: 0
Hi,
I'm trying to create some rows in a table using php code.
Its like this:
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.
I'm trying to create some rows in a table using php code.
Its like this:
PHP Syntax (Toggle Plain Text)
<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.
•
•
Join Date: Sep 2004
Posts: 25
Reputation:
Solved Threads: 0
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.
[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.
•
•
Join Date: Oct 2004
Posts: 7
Reputation:
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.
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.
![]() |
Similar Threads
- html table in php code. (PHP)
- php code within <html> not showing (PHP)
- Using HTML tags in PHP code (PHP)
- error parsing php code (PHP)
Other Threads in the PHP Forum
- Previous Thread: PHP file handling
- Next Thread: How many clients can access a PHP script at a time?
| Thread Tools | Search this Thread |
advanced alerts apache api archive array autosuggest beginner binary broken cakephp checkbox class clients cms code cron curl database date datepart display dynamic echo email emptydisplayvalue eregi error execute explodefunction file files folder form forms function functions google hack head href htaccess html if...loop image include insert ip javasciptvalidation javascript joomla keywords library limit link login mail matching menu mlm multiple mysql number object oop password paypal pdf php phpincludeissue query radio random recursive remote script search searchbox server sessions shot smarty source space speed sql syntax system table tutorial update upload url validator variable vbulletin video web website youtube





