okrobie Posted May 3, 2010 Share Posted May 3, 2010 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>"); } Quote Link to comment https://forums.phpfreaks.com/topic/200503-text-formatting-in-echo/ Share on other sites More sharing options...
trq Posted May 3, 2010 Share Posted May 3, 2010 You haven't exactly described the problem. Quote Link to comment https://forums.phpfreaks.com/topic/200503-text-formatting-in-echo/#findComment-1052169 Share on other sites More sharing options...
okrobie Posted May 3, 2010 Author Share Posted May 3, 2010 Sorry if I wasn't clear. I want to format the text that is output from the ECHO statement but I can only format the fixed part of the output. The variables come out in the default font. How do I format the output of the variables? Quote Link to comment https://forums.phpfreaks.com/topic/200503-text-formatting-in-echo/#findComment-1052176 Share on other sites More sharing options...
trq Posted May 3, 2010 Share Posted May 3, 2010 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 />"); Quote Link to comment https://forums.phpfreaks.com/topic/200503-text-formatting-in-echo/#findComment-1052179 Share on other sites More sharing options...
okrobie Posted May 3, 2010 Author Share Posted May 3, 2010 Thanks Thorpe, I appreciate your help. That is a good start, but actually I want the variables in h4 instead. Quote Link to comment https://forums.phpfreaks.com/topic/200503-text-formatting-in-echo/#findComment-1052181 Share on other sites More sharing options...
trq Posted May 3, 2010 Share Posted May 3, 2010 So put them with <h4> tags. Quote Link to comment https://forums.phpfreaks.com/topic/200503-text-formatting-in-echo/#findComment-1052184 Share on other sites More sharing options...
okrobie Posted May 3, 2010 Author Share Posted May 3, 2010 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>"); } Quote Link to comment https://forums.phpfreaks.com/topic/200503-text-formatting-in-echo/#findComment-1052185 Share on other sites More sharing options...
trq Posted May 3, 2010 Share Posted May 3, 2010 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>"; Quote Link to comment https://forums.phpfreaks.com/topic/200503-text-formatting-in-echo/#findComment-1052187 Share on other sites More sharing options...
okrobie Posted May 3, 2010 Author Share Posted May 3, 2010 That is very helpful... Thanks!!! Quote Link to comment https://forums.phpfreaks.com/topic/200503-text-formatting-in-echo/#findComment-1052190 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.