Jump to content

Trouble Creatine Two Column Table


warrenk

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.