Solved

php formating html table cell

Posted on 2011-09-14
5
303 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 56

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 56

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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

623 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