Jump to content

Echo table statement won't work


crmamx

Recommended Posts

// Other code
//echo "<table border='10' cellpadding='3' cellspacing='2'>";  This works
echo "<table class="my-table">";                                     //This does not work
echo "<tr><th>First Name</th><th>Last Name</th><th>Home Phone</th><th>Cell Phone</th><th>email</th></tr>";

// keeps getting the next row until there are no more to get ================

while($row = mysql_fetch_array( $result )) {

// Print out the contents of each row into a table ==========================

echo "<tr><td>";
echo $row['first'];
echo "</td><td>";
echo $row['last'];
echo "</td><td>";
echo $row['phone'];
echo "</td><td>";
echo $row['cell'];
echo "</td><td>";
echo $row['email'];
echo "</td></tr>"; 
} 
echo "</table>";
?>

Error message:

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/bayare27/public_html/content/pages/display_all_members1.php on line 29

Line 29 is:  echo "<table class="my-table">";                                     

 

<table class="my-table">" is a valid statement because It works in another program, but html not php                                   

Link to comment
Share on other sites

slash out the quotes

The enclosed quotes need to be escaped with a backslash.

You guys talk a foreign language.. ;)

 

But I was able to Google it and find how to do it. Works like a charm.

 

My undersized brain would have understood the single quotes but that wasn't posted until after I researched the other.

 

Many thanks.

Link to comment
Share on other sites

That's a good thing, then. It means you learned another piece of valuable information about PHP's syntax.

 

You are right. First time I have ever encountered that. I am sure I must have read about it in the tutorials but it did not stick with me.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.