Jump to content


Photo

PHP echo Question


  • Please log in to reply
10 replies to this topic

#1 vund0

vund0
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 27 July 2006 - 02:18 AM

I need to change the font color and size for this code:

echo "<tr><td>" . $rows['lastname'] . " " . $rows['firstname'] . "</td><td>" . $rows['company'] . "</td><td>" . $rows['email'] .  "</td><td>" . $rows['homephone'] . "</td></tr>";

Any Ideas?

#2 rab

rab
  • Members
  • PipPipPip
  • Advanced Member
  • 155 posts

Posted 27 July 2006 - 02:20 AM

Either use the font tag, depreciated, or give the tag an id or a class and give that class a style. Check more out at w3schools.com -> CSS

#3 vund0

vund0
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 27 July 2006 - 02:36 AM

Rab thanks for your help but Ive looked at w4schools and I am still confused.  I dont need to use css, I just want to know the font tag should be implimented into my code.

#4 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 27 July 2006 - 02:42 AM

echo "<tr><td><font color='red' size='2'>". $rows['lastname']. "</font></td><td> ..... etc

That will do what you want, but it's far from the best and simplest.  Use a single style for the td element would be so much cleaner. Your choice.
Legend has it that reading the manual never killed anyone.
My site

#5 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 27 July 2006 - 02:44 AM

lol ^ same thing

try this

echo '<tr>
            <td><font color="#000000">' . $rows['lastname'] . ' ' . $rows['firstname'] . '</font</td>
            <td><font color="#000000">' . $rows['company'] . '</font></td>
            <td><font color="#000000">' . $rows['email'] .  '</font></td>
            <td>' . $rows['homephone'] . '</td>
       </tr>';

Try using single quotes instead of double

Hope this helps,
Tom

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#6 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 27 July 2006 - 09:59 AM

Just style the row tag!:
echo '<tr style="color:#000000; font-size:10px;">
            <td>' . $rows['lastname'] . ' ' . $rows['firstname'] . '</td>
            <td>' . $rows['company'] . '</td>
            <td>' . $rows['email'] .  '</td>
            <td>' . $rows['homephone'] . '</td>
       </tr>';

That'll now affect all the text within that row. It'll change the text to black and resixe the font to 10px.

#7 vund0

vund0
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 27 July 2006 - 11:10 PM

Thanks, that helped a lot.  But now I have another question.  When the users website is displayed I want to know how to make it a link.  I tried messing around with it and heres what I got so far:

echo "<tr><td><font color='white' size='2'>" . $rows['coname'] . "</font></td><td><font color='white' size='2'>" . $rows['buisnessphone'] . "</font></td><td><font color='white' size='2'>" . $rows['coemail'] . "</font></td><td><font color='white' size='2'>". "<a href=['website']>" . $rows['website'] . "</font></td></tr>";

Thanks for your help

#8 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 27 July 2006 - 11:14 PM

You need to add the closing tag for the link
Legend has it that reading the manual never killed anyone.
My site

#9 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 27 July 2006 - 11:19 PM

do this

'<a href="' . $rows['website'] . '">' . $rows['website'] . '</a>'

The reason that I said to use the single quotes
'
instead of double quotes
"
is that it would make it easier for useing things that require double quotes. Also I would recommend cleaning up your code a bit. Something more like what wildteen or myself posted would make it easier to add new fields or for debugging.

Good luck,
Tom

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#10 vund0

vund0
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 31 July 2006 - 05:30 PM

Ok, I now have another problem.... The website link comes up fine, but for some reason its using the root with the website.  For example instead of being qnpi.com its http://npia.us/www.qnpi.com and I just need it to be qnpi.com you can see it at

http://npia.us/cmemberlist.php

Here's my code:

echo '<tr style="color:#ffffff; font-size:12px;">
            <td>' . $rows['coname'] . '</td>
            <td>' . $rows['buisnessphone'] . '</td>
            <td>' . $rows['coemail'] .  '</td>
            <td>' . '<a href="' . $rows['website'] . '">' . $rows['website'] . '</a>' . '</td>
       </tr>';

Also I would like to change the color of the link to make it more visible

Thanks for your help

#11 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 31 July 2006 - 05:55 PM

That's happening because you didn't specify the "http://" in the generated URL.

Try this:
<?php
echo '<tr style="color:#ffffff; font-size:12px;">
            <td>' . $rows['coname'] . '</td>
            <td>' . $rows['buisnessphone'] . '</td>
            <td>' . $rows['coemail'] .  '</td>
            <td>' . '<a href="http://' . $rows['website'] . '">' . $rows['website'] . '[/url]' . '</td>
       </tr>';
?>

Ken




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users