Jump to content

Recommended Posts

Hello, I'm having trouble formatting the variables in this snippet. As you can see, I can format the first part of the text. Can someone please help?

{ 
echo ("<h3>Teachers Name: </h3>" . $row["first_name"]);
echo (" " . $row["last_name"]."<br>"."<br>");
echo nl2br("<h3>Teachers Message: </h3>" . $row["teacher"]."<br>"."<br>");
}

Link to comment
https://forums.phpfreaks.com/topic/200503-text-formatting-in-echo/
Share on other sites

Assuming you want them to be within the <h3> tags, you just need to place them within those tags.

 

echo "<h3>Teachers Name:" . $row["first_name"] . "</h3>";
echo $row["last_name"] . "<br /><br />";
echo nl2br("<h3>Teachers Message: " . $row["teacher"] . "</h3><br /><br />");

Thank you, I was able to get it from what you gave me.

{ 
echo ("<h3>Teachers Name: </h3>" . "<h4>" . $row["first_name"] . "</h4>");
echo (" " . "<h4>" . $row["last_name"] ."</h4>" . "<br>"."<br>");
echo nl2br("<h3>Teachers Message: </h3>" . $row["teacher"]."<br>"."<br>");
}

echo does not require () braces, your also overdoing the concatenation. Your code could be simplified quite a bit.

 

echo "<h3>Teachers Name: </h3><h4>" . $row["first_name"] . "</h4>";
echo "<h4>" . $row["last_name"] . "</h4><br><br>";
echo "<h3>Teachers Message: </h3>" . nl2br($row["teacher"]) . "<br><br>";

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.