Jump to content


Photo

Trouble Creatine Two Column Table


  • Please log in to reply
3 replies to this topic

#1 warrenk

warrenk
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 06 August 2006 - 06:23 PM

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

#2 ignace

ignace
  • Moderators
  • Now mod flavored
  • 6,430 posts
  • LocationBelgium

Posted 06 August 2006 - 06:25 PM

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

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

#3 warrenk

warrenk
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 06 August 2006 - 06:26 PM

Your replay couldn't of come more then a minute after I posted the question.  :o

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

#4 ignace

ignace
  • Moderators
  • Now mod flavored
  • 6,430 posts
  • LocationBelgium

Posted 06 August 2006 - 06:29 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users