mardi 5 mai 2015

HTML/PHP Table Formatting

I'm very new to both HTML and PHP and I'm trying to get my table formatting right. I'm importing information from a database and it's all coming through correctly.

This is my code for my table

    echo "
    <tr>
    <td>".$row["id"]."</td>
    <td><center>".$row["firstname"]." ".$row["lastname"]."</center></td>
    <td><center>".$row["addr1"]."<br>".$row["addr2"]."<br>".$row["city"].",".$row["state"]." ".$row["zip"]."</center></td>
    <td>".$row["phone"]."</td>
    </tr>";

In my database, if a phone number was not entered it's saved as 0. Otherwise the number is saved as 5556667777. How can I format output in HTML so that my phone number is (555)-666-7777.

Also, the way I coded the address it should show up as

567 Main Street
Apt 4
New York, New York 88888

but if there's no information in the addr 2 (ie Apt 4) there's a blank space. Can I put a conditional inside html to remove this?

Aucun commentaire:

Enregistrer un commentaire