0

I have a css question. I have the following php code which displays a name.

 while ($db_field = mysql_fetch_assoc($result)) {
        print $db_field['ship_name'] . "<BR>";

I'm trying to add some text style to it but I'm not that good in css and I'm somehow lost. I'm trying to do something like <t> $db_field['ship_name'].<t/> but it gives me an error.

3
  • <t> is not a valid CSS style, what are you trying to achieve with that? Commented Sep 28, 2011 at 3:48
  • i have them defined in my css file such ass : t { font-size: 50pt; color:black; text-shadow: 0 1px 2px white;} .... im trying to style the output from the php code. Commented Sep 28, 2011 at 3:51
  • You should include that in your question. Commented Sep 28, 2011 at 3:59

3 Answers 3

1

judging by your comment, probably you want

print "<span class='t'>".$db_field['ship_name']."</span><BR>";

and for your CSS file define

.t {  font-size: 50pt; color:black; text-shadow: 0 1px 2px white; }
Sign up to request clarification or add additional context in comments.

2 Comments

print "<t>".$db_field['ship_name']."</t><BR>";
my css : t { font-size: 50pt; color:black; text-shadow: 0 1px 2px white;}
0

There are 2 ways of doing this. Either you embed html in PHP or write separate HTML snippet. I will show you the both ways : The first one is already explained above in the answer by sinclairchase.

echo "<td>" . $db_field['ship_name'] . "</td>";

The other way is :

<?php while ($db_field = mysql_fetch_assoc($result)) {
 ?>
   <td>
      <?php print $db_field['ship_name'] . "<BR>"; ?>
   </td>
 <?php  }  ?>

I dont unsderstand why you write t in question it would be td.

Comments

0

This will echo out the data into a span tag:

echo "<span>" . $db_field['ship_name'] . "</span>";

To add a css class:

echo "<span class=\"class_name\">" . $db_field['ship_name'] . "</span>";

Then in your css file:

span.class_name { font-size:24px; color:#666; }

5 Comments

a table cell interferes with my design, is there any way to apply the formatting directly to the text?
You're going to want to do it via css and not in the actual html that the php is outputting. I think you should look at a css primer, if you're unfamiliar. There are a ton of resources on the web.
It doesn't have to be a table cell either. You could output into a list, paragraph, or whatever html tag you need to use. That will eleviate the need for the BR tag. Ultimately, you want to use css for styling. Makes life so much easier.
@user964535 If it's not in a table then use a <span> tag instead of a <td> tag. That's as close as you can get to "directly to the text", <span> is an inline element so it will not disrupt the page flow.
my apologies but i was not using a <td> merely a styled css that i happened to name <t>. im sorry for the confusion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.