Jump to content

Recommended Posts

I am trying to create a 2 column table and keep getting a error...

Parse error: parse error, unexpected T_LNUMBER, expecting ',' or ';' in /home/reviews/public_html/brand1.php on line 16

The line in error is:
echo "<table width="180" border="1" cellspacing="2" cellpadding="0">";

Here is some of the code...

$result = mysql_query("select * from brands");

$count = 1;
$column = 1;

echo "<table width="180" border="1" cellspacing="2" cellpadding="0">";

//grab all the content
while($r=mysql_fetch_array($result))
{
// first column display
if ($column == 1)
{

//field is the column in your table
printf("<tr><td>%s</td>",$r["brand_name"]);
}

else{
//second column display 
printf("<td>%s</td></tr>",$r["brand_name"]);
}

$count += 1;

$column = $count % 2;
}

echo "</table>";
Link to comment
https://forums.phpfreaks.com/topic/16726-trouble-creatine-two-column-table/
Share on other sites

change
[code]echo "<table width="180" border="1" cellspacing="2" cellpadding="0">";[/code]
to
[code]echo "<table width='180' border='1' cellspacing='2' cellpadding='0'>";[/code]

when you open something with ", then make sure whenever you again need something between quotes, then use ' because when you use " again, it means your closing it..

so this
[code]echo "<table width="180" border="1" cellspacing="2" cellpadding="0">";[/code]
would only work if you would do this
[code]echo "<table width=" . 180 . " border=" . 1 . " cellspacing=" . 2 . " cellpadding=" . 0 . ">";[/code] the . means your attaching it.
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.