Really Quick PHP question

Venom

Seasoned Veteran
Joined
Sep 12, 2012
Messages
3,798
Reaction score
0
FP$
0
Hi, How could I add formatting to the following php code?

Code:
echo $arr[0] . '<br />'; // Total users.

I managed to add formatting to:

Code:
echo '<font face="verdana" color="green" span style="font-size:12px">This is some text!</font>';

Please Help, Thanks. 🙂
 
Code:
echo '<font face="verdana" color="green" span style="font-size:12px">This is some text!</font>';

Should be:

Code:
echo '<p style="font-face:verdana, sans-serif; color:green; font-size:12px">This is some text!</p>';

Nothing to do with PHP, just a bit of inline CSS
 
Thanks, but I mean how do I apply styling to the 1st example of code I posted?. The 2nd was just to explain what I want. 🙂
 
I believe you wish to have arr[o] value instead of "This is some Text" ?

if so you can do it like this. 🙂

Code:
echo '<font face="verdana" color="green" span style="font-size:12px">'. $arr[0] .'</font>';
 
Thankyou Kavin, exacly what I wanted.

Thanks to everyone else too. 🙂
 
you can add the HTML style to the result being pulled from the database by putting the HTML into the database. When you call for the result with sql it will pull the HTML from the database and display it correctly.

I hope that makes sense... :shrug:
 
R44 said:
Code:
echo '<font face="verdana" color="green" span style="font-size:12px">This is some text!</font>';

Should be:

Code:
echo '<p style="font-face:verdana, sans-serif; color:green; font-size:12px">This is some text!</p>';

Nothing to do with PHP, just a bit of inline CSS

Inline CSS? You crazy? Use a separate stylesheet and apply classes to the elements.

InterNauert said:
you can add the HTML style to the result being pulled from the database by putting the HTML into the database. When you call for the result with sql it will pull the HTML from the database and display it correctly.

I hope that makes sense... :shrug:

Wut lol, probably one of the most stupid ways to do it. You shouldn't really keep your HTML in a database.
 
InterNauert said:
you can add the HTML style to the result being pulled from the database by putting the HTML into the database. When you call for the result with sql it will pull the HTML from the database and display it correctly.

I hope that makes sense... :shrug:

It would result in every row of the table having same html code around the value. When you develop an app your first priority should be to reduce as much code complexity as possible.
Suppose if you decided to change an attribute in the html, you would end up writing a SQL function or write a converter which grabs all results and update it with replaced code.
 
ShadyX said:
Wut lol, probably one of the most stupid ways to do it. You shouldn't really keep your HTML in a database.
XenForo does it. 😉
 
terryh said:
ShadyX said:
Wut lol, probably one of the most stupid ways to do it. You shouldn't really keep your HTML in a database.
XenForo does it. 😉

I believe they store templates in DB? (Never used Xenforo so not sure).

And the thing is, ShadyX says you shouldn't store values with templates in it in database. Storing template is ok, but your system should get values and embed them i template. It shouldn't store template with value directly.
 
terryh said:
XenForo does it. 😉

Just because XenForo practices bad coding practice (but they probably have a reason for it, like templating through the ACP or something) doesn't mean that everyone else needs to follow suit.

I, for one, do not do that.
 
Back
Top Bottom