Jump to content

Archived

This topic is now archived and is closed to further replies.

vund0

PHP echo Question

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[code]echo "<tr><td><font color='red' size='2'>". $rows['lastname']. "</font></td><td> ..... etc[/code]

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.

Share this post


Link to post
Share on other sites
lol ^ same thing

try this

[code=php:0]
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>';[/code]

Try using single quotes instead of double

Hope this helps,
Tom

Share this post


Link to post
Share on other sites
Just style the row tag!:
[code=php:0]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>';[/code]

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
You need to add the closing tag for the link

Share this post


Link to post
Share on other sites
do this

[code=php:0]
'<a href="' . $rows['website'] . '">' . $rows['website'] . '</a>'
[/code]

The reason that I said to use the single quotes [code=php:0]'[/code] instead of double quotes [code=php:0]"[/code] 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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
That's happening because you didn't specify the "http://" in the generated URL.

Try this:
[code]<?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>';
?>[/code]

Ken

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.