Jump to content

PHP echo Question


vund0

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.