Click to See Complete Forum and Search --> : [RESOLVED] Altering attributes of dynamic table


sonny100
04-22-2009, 06:16 PM
Hi there,

I am wondering how I go about altering many of the attributes in a table that's nested in a while loop.

I can change some of the attributes of the row, such as width etc, but I want to be able to change the border style etc, which I can't seem to figure out.

The code looks like this...


echo "

<TR>
<TD width=75><a href= 'masterdetails.php?id={$row['ID']}''><img src=upload_images/{$row['photo']} width=150 height=125 /></a></TD>
<TD width=300 align=left >{$row['username']}<p>{$row['age']}<p>{$row['location']}</TD>
<TD width=300>Interests<p>{$row['interest1']}<p>{$row['interest2']}<p>{$row['interest3']}</TD>
</TR>";


Do you know if I can attach a style sheet to a cell in the above code? (i'm not too experienced with CSS)

I seem to be limited to what I can amend in these cells because they're within the PHP tags.

Any help would be appreciated!

Cheers,

dagon
04-22-2009, 06:24 PM
this is a client side issue, you can add a class or id to the row or use inline css

<td style="border: 2px solid #f00" ..

bradgrafelman
04-22-2009, 07:13 PM
I seem to be limited to what I can amend in these cells because they're within the PHP tags.How does using PHP restrict what HTML you can output in anyway?

sonny100
04-22-2009, 08:27 PM
Well generally when adding attributes to a HTML table, you put the variable in double quotes, which I can't seem to do here because it's not recognised within the echo double quotes.

<TD width=300 style="border: 2px solid #f00" align=left>{$row['username']}<p>{$row['age']}<p>{$row['location']}</TD>

This doesn't work beacuse it doesn't like the double quotes in there....

dagon
04-22-2009, 08:33 PM
echo ' """"""""" ';

bradgrafelman
04-22-2009, 08:38 PM
This doesn't work beacuse it doesn't like the double quotes in there....That's because you didn't escape them properly; when literal double quotes appear inside of a double-quote delimited string, you must escape the literal double quotes so that PHP doesn't know you're trying to end the string and do something else.

More information on this can be found in the manual for the string type.

sonny100
04-22-2009, 08:52 PM
Nice one, sorted.

Thanks

bradgrafelman
04-22-2009, 08:53 PM
Glad we could help. Don't forget to mark this thread resolved (if it is) using the link under the Thread Tools menu.