Page 1 of 1

How to Formatting Text inside <?php ?> tags? [UNSOLVED]

Posted: Sun Jul 17, 2011 7:15 am
by RafliArema
How to formatting text inside the php tags?

EXAMPLE:

Code: Select all

<?php
include_once 'connect.php';
?>
<?php
$bypass = 0;
$playerinfo="SELECT * from players where name='$player'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
$playergold = $playerinfo3['gold'];
$playerlevel = $playerinfo3['level'];
$playerexp = $playerinfo3['exper'];
$playername = $playerinfo3['name'];
$playertribes = $playerinfo3['tribes'];
$playerlocation = $playerinfo3['location'];
?>


<link rel="stylesheet" href="gpack/inside.css" type="text/css" />
<div class="Standard">
              <ul class="Standard">
            <li class="Standard">Username: <?php print $playername; ?></li>
            <li>Level: <?php print $playerlevel; ?></li>
            <li>Pengalaman: <?php print $playerexp; ?></li>
            <li>Suku: <?php print $playertribes; ?></li>
            <li>Lokasi: <?php print $playerlocation; ?></li>
            <li>Jumlah Emas: <?php print $playergold; ?></li>
            </ul>
            </div>
The Output of the code above is just a plain text.... No format...
My question, is how to formatting the text inside the <?php print $variables ?> ??
Format the $variables, like font colors, size, etc


Thank you for help me out....
I will put [SOLVED] on the title if this problems solved :)

Re: How to Formatting Text inside <?php ?> tags? [UNSOLVED]

Posted: Sun Jul 17, 2011 7:36 am
by 62896dude
Assuming that you are familiar with div tags, all you have to do to use a div tag in PHP is use:

Code: Select all

echo "<div id='div_name_here_from_style.css'>";
echo "blah blah blah text text content blah";
echo "</div>";
That's all it takes, you just have to make sure that when you are using a div id, the id that you reference must already be in your style.css, and that is where you format that id

Re: How to Formatting Text inside <?php ?> tags? [UNSOLVED]

Posted: Sun Jul 17, 2011 7:47 am
by RafliArema
Thank you for try to help me out,
But it's 100% not working...

What do you mean with div id?
Do you mean file name.css?




Rafli
[STILL UNSOLVED]

Re: How to Formatting Text inside <?php ?> tags? [UNSOLVED]

Posted: Sun Jul 17, 2011 6:28 pm
by Jackolantern
Do you know how to use CSS? That is how all text should be formatted. You can either wrap an entire block in a div like:

Code: Select all

<div id="myDiv">This is a text block. Most browsers will put space above and below it.</div>
Or you can use a span tag, which is commonly used for adding formatting to only a segment of a text block:

Code: Select all

<p>This is another text block. However, I <span id="mySpan">may</span> want to format only part of it.</p>
Then you can use those IDs to style your text anyway you want:

Code: Select all

#myDiv {
     text-align: right;
     color: blue;
}

#mySpan {
     font-style: italic;
}

Re: How to Formatting Text inside <?php ?> tags? [UNSOLVED]

Posted: Sun Jul 17, 2011 7:41 pm
by 62896dude
good explanation Jack, that is what you should be doing Rafli

Re: How to Formatting Text inside <?php ?> tags? [UNSOLVED]

Posted: Mon Jul 18, 2011 7:23 am
by RafliArema
I already put

#UserStats {
color: blue; font-size:36px;
}

on style.css, but when Im
<?php echo "<div id='UserStats'>";
echo $playername;
echo "</div>";?>

It doesn't change....
The style is same like before....

I confused,
Please help me....

Re: How to Formatting Text inside <?php ?> tags? [UNSOLVED]

Posted: Mon Jul 18, 2011 2:28 pm
by hallsofvallhalla
or simplify it and add HTML

Code: Select all

echo "<font color='#FFFFFF'> Hello </font><b><u>World</u></b>";

Re: How to Formatting Text inside <?php ?> tags? [UNSOLVED]

Posted: Mon Jul 18, 2011 6:37 pm
by Jackolantern
Formatting HTML really shouldn't be used. It is deprecated, and browsers are free to remove support at any time. Of course, they likely won't, but that is the danger of using deprecated tags.

Re: How to Formatting Text inside <?php ?> tags? [UNSOLVED]

Posted: Mon Jul 18, 2011 7:26 pm
by 62896dude
Do you have the link href tag or whatever its called in your code to reference style.css? If not, that is your problem

Re: How to Formatting Text inside <?php ?> tags? [UNSOLVED]

Posted: Mon Jul 18, 2011 10:01 pm
by hallsofvallhalla
They will support it forever most likely. Not sure why anyone would want to create a CSS div for everything that is bolded. Or even use the same one. Kinda silly. You can create a div to bold one word or put b tags around it. Standard HTML. Don't see how using HTML is considered bad and if it is then everyone has went way too far on the standards bandwagon.