Solved

php formating html table cell

Posted on 2011-09-14
5
296 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

758 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

15 Experts available now in Live!

Get 1:1 Help Now