Solved

php formating html table cell

Posted on 2011-09-14
5
297 Views
Last Modified: 2012-05-12
I need some help with formatting a HTML table cell in an HTML email created in a php script. What I want is a list of number aligned in the table cell vertically. What I get is a list of numbers  all in one line in the cell.

 
// email.
    $to = "someone@gmail.com";
    $from = "root@me.com";
    $subject = "Hello! This is HTML email";

    //begin of HTML message
     
$message ='<html>
  <body bgcolor="#DCEEFC">
    <center>
        <b> I am reciving HTML email......</b> <br>
        <font color="red">Thanks !</font> <br>
        <?=$IMEI?>
    </center>
      <table border="1">
<tr>
<td >';
 while ($line =  mysql_fetch_assoc($result)) {
     	
     	$message .=    $line['num']. " \n";
     	
     }
$message.= '</td>

</tr>
</table> 
  </body>
</html>';

   //end of message
    $headers  = "From: $from\r\n";
    $headers .= "Content-type: text/html\r\n";

   
    
    // now lets send the email.
    mail($to, $subject, $message, $headers);

    echo "Message has been sent....!";

Open in new window

0
Comment
Question by:pointhigh
5 Comments
 
LVL 6

Accepted Solution

by:
bartvd earned 425 total points
ID: 36538891
You should replace this line:
$message .=    $line['num']. " \n";

in this line:
$message .=    $line['num']. "<br />";
0
 
LVL 51

Expert Comment

by:HainKurt
ID: 36538921
you can also use <li>

$message .=    "<li>" .$line['num'];
0
 
LVL 10

Assisted Solution

by:stu215
stu215 earned 25 total points
ID: 36539022
-> you can also use <li>
->
-> $message .=    "<li>" .$line['num'];

Dont forget to close the <li>...</li> ::

$message .=    "<li>".$line['num']."</li>";
0
 
LVL 51

Assisted Solution

by:HainKurt
HainKurt earned 50 total points
ID: 36539492
actually we should include <ol>...<ol> or <ul>...</ul> too :)

$message.= '<ul>';
while ($line =  mysql_fetch_assoc($result)) {
  $message .=    "<li>".$line['num']."</li>"." \n";
}
$message.= '</ul>';

for lines: 18-22
0
 

Author Closing Comment

by:pointhigh
ID: 36542695
This worked great! Thanks!
I tested everyone’s solution and they all worked. Bartvd solution was the closest to what I was looking for.
Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn how to dynamically set the form action using jQuery.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now