How to Display a PHP Variable in HTML Table in an Echo?

Discuss The roots and branches of Web Designing. Discuss on HTML XML Domains Web Hosting PHP ASP CAPNEL... all about web designing...
Posts: 37
Joined: Tue Sep 28, 2010 11:45 am

How to Display a PHP Variable in HTML Table in an Echo?

Postby doll » Mon Nov 29, 2010 10:56 am

I have the following part of a PHP code below.

echo '<table width="400" border="1" cellspacing="0" cellpadding="3"><tr><td width="30%">echo $rows['name'];</td><td width="30%">echo $rows['lastname'];</td><td width="30%">echo $rows['email'];</td></tr></table>';

I am trying to echo a row from a database, but it's not working. How can I echo the $row variable in the code?

User avatar
Site Admin
Posts: 612
Joined: Sun Dec 21, 2008 12:14 pm

Re: How to Display a PHP Variable in HTML in an Echo?

Postby dilip » Mon Nov 29, 2010 11:27 am

the code is quiet confusing... there is no need to use and echo in an echo ... there are lot of syntax errors..

You can use the following code and can ask back if there is any problem

Code: Select all

<table width="400" border="1" cellspacing="0" cellpadding="3">
<tr><td width="30%">
<?php echo $rows['name']; ?>
</td><td width="30%">
<?php echo $rows['lastname']; ?>
</td><td width="30%">
<?php echo $rows['email']; ?>

And don't forget to close down php with '?> ' before the <table ..> tag
The code will be simpler and straight avoiding confusion. I generally escape out from PHP to output HTML... :D

Return to “Web Designing”

Who is online

Users browsing this forum: No registered users and 1 guest