hello all,
i need html table to be inserted in php code..i tried this but i am getting some problem with it so can anyone help me..
Thank u..

$messageproper ="\n\n" .
		"Name: " .
		ucwords($_POST['name']) .
		"\n" .
		"Email: " .
		ucwords($email) .
		"\n" .
		"Message: " .
		$_POST['message'] .
		"\n" .
		"\n\n" ;

i need this Name,Email and Message to be in a table..

You have no html in that code!...

<?php

  // ---- your code ---- //

?>
<html>
<table>
  <tr>
      <td>name</td>
      <td>email</td>
      <td>message</td>
  </tr>
  <tr>
      <td><?php ucwords($_POST['name']); ?></td>
      <td><?php ucwords($email); ?></td>
      <td><?php $_POST['message']; ?></td>
  </tr>
</table>
</html>

tr creates a new row, td creates a new cell

no i dont had any html code init..Once check the code i had posted..Name,Email,Message are assigned to $messageproper.

But name message and email are individual variables being assigned to $messageproper. So my code should work.

ok..now how can we assign them to $messageproper.

So you want the table with the values in, and then assign them to $messageproper? What are you using messageproper for?

You can do it exactly the same way as you'd done previously. I'm not sure if you still want the line breaks in there or not though.

// table with the values goes here...


//then assign the values to the messageproper variable.
$messageproper ="\n\n" .
		"Name: " .
		ucwords($_POST['name']) .
		"\n" .
		"Email: " .
		ucwords($email) .
		"\n" .
		"Message: " .
		$_POST['message'] .
		"\n" .
		"\n\n" ;

ok..i am posting my full code here..actually this for sending mail.It is working fine.But the mail appears very ordinary..I need that to be in a table with some background color..

<?
$mailto = "xxx@gmail.com";
$cc = "";
$bcc = "";
$subject = "Mail received";
$vname = $_POST['name'];
$email = $_POST['email'];
function validateEmail($email)
{
   if(eregi('^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z]{2,4}(\.[a-zA-Z]{2,3})?(\.[a-zA-Z]{2,3})?$', $email))
	  return true;
   else
	  return false;
}
if((strlen($_POST['name']) < 1 ) || (strlen($email) < 1 ) || (strlen($_POST['message']) < 1 ) || validateEmail($email) == FALSE){
	$emailerror .= 'Error:';

	if(strlen($_POST['name']) < 1 ){
		$emailerror .= '<li>Enter name</li>';
	}

	if(strlen($email) < 1 ){
		$emailerror .= '<li>Enter email</li>';
	}

	if(validateEmail($email) == FALSE) {
		$emailerror .= '<li>Enter valid email</li>';
	}

	if(strlen($_POST['message']) < 1 ){
		$emailerror .= '<li>Enter message</li>';
	}

} else {

	$emailerror .= "<span>Your email has been sent successfully!</span>";



	// NOW SEND THE ENQUIRY

	$timestamp = date("F j, Y, g:ia");

	$messageproper ="\n\n" .
		"Name: " .
		ucwords($_POST['name']) .
		"\n" .
		"Email: " .
		ucwords($email) .
		"\n" .
		"Message: " .
		$_POST['message'] .
		"\n" .
		"\n\n" ;

		$messageproper = trim(stripslashes($messageproper));
		mail($mailto, $subject, $messageproper, "From: \"$vname\" <".$_POST['e_mail'].">\nReply-To: \"".ucwords($_POST['first_name'])."\" <".$_POST['e_mail'].">\nX-Mailer: PHP/" . phpversion() );

}
?>

<div id='emailerror'>
	<ul>
		<? echo $emailerror; ?>
	</ul>
</div>
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];

$propermessage = "Name:\n ucwords($name)\n Email:\n $email\n Message:\n $message\n\n\n";

when you uses $propermessage variable again us it with the nl2br function

echo nl2br($propermessage);

thanks for ur response...But wat i exactly need is..to put Name,Email,Message in a table..so can we do that..

$messageproper = "<table>
                   <tr>
                      <td>name</td>
                      <td>email</td>
                      <td>message</td>
                   </tr>
                   <tr>
                      <td>".ucwords($_POST['name'])."</td>
                      <td>".ucwords($email)."</td>
                      <td>".$_POST['message']."</td>
                   </tr>
                 </table>";

echo $messageproper;

Something like this should work but check the syntax, you might need to play around with the quotes to get it working properly...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.