# Solved: Table width as percentage in php



## deepdiver01 (Dec 23, 2004)

Hi all.

Am tidying up a site for a friend and have run into a problem.

I am trying to give a table cell a width expressed as a percentage. The table layout in this instance is within a php variable, thus


```
printf("<td class='textMain' width='300' bgcolor='%s' align='left'><a href=user.php?userid=%s>%s</a>
</font></td>", $rowcolorhex, $myrow["userid"], $myrow["title"]);
```
I am trying to set width to 60%, however when I try the following it breaks


```
printf("<td class='textMain' width='60%' bgcolor='%s' align='left'><a href=user.php?userid=%s>%s</a>
</font></td>", $rowcolorhex, $myrow["userid"], $myrow["title"]);
```
Is there a way to use the percentage sign within php? Have tried \ to no avail.

Thanks


----------



## cpscdave (Feb 25, 2004)

try 

```
print("<td class='textMain' width='60%' bgcolor='{$rowcolorhex}' align='left'><a href=user.php?userid={$myrow['userid']}>{$myrow['title']}</a>
</font></td>");
```


----------



## deepdiver01 (Dec 23, 2004)

Thanks for that cpscdave.

That worked fine.

What I cannot understand is why the percentage sign was breaking the old code but not the new.

What is the reason for this.


----------

