Jump to content

Archived

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

warrenk

Trouble Creatine Two Column Table

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>";

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
Your replay couldn't of come more then a minute after I posted the question.  :o

Really appreciate your help....and fast reply!!!!

Share this post


Link to post
Share on other sites
we didn't get the name of best php forum, not for nothing... ofcourse i'm not the one getting any credit for this, this goes to the guys that started phpfreaks.com

Share this post


Link to post
Share on other sites

×

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.