Morris2 Posted October 11, 2011 Share Posted October 11, 2011 Hi. In the code below I want to style the variable total and the word USD from a customized stylesheet. I tried to make this work based on a previous answer, but i failed. I know now how to style a paragraph in HTML from CSS, but don't have a clue about how to style a variable. Best regards Morris. while($row = mysql_fetch_assoc($chart)) {echo $row['artist']."..." .$row['city']." " .$row['country']." " .$row['total']." USD<br>";} Quote Link to comment Share on other sites More sharing options...
trq Posted October 11, 2011 Share Posted October 11, 2011 I know now how to style a paragraph in HTML from CSS, but don't have a clue about how to style a variable. PHP does nothing special, it is generally used to output HTML. <span class="foo"><?php echo $somevariable; ?></span> Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted October 11, 2011 Share Posted October 11, 2011 well you can parse some HTML to wrap around the variable and style it.. in this case lets say a span.. like so.. echo "<span class='testCSS'>".$row['total']." USD</span>"; then style the span however you want the text to look like.. Edit: thorpe beat me to it.. Quote Link to comment Share on other sites More sharing options...
Morris2 Posted October 11, 2011 Author Share Posted October 11, 2011 Thanks! I will have to insert this line within the while loop, so all the totals and USD in this list will be styled. But where in my code do I insert this line??: echo "<span class='testCSS'>".$row['total']." USD</span>"; With or without the echo word? Will you show me? Thanks Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted October 11, 2011 Share Posted October 11, 2011 while($row = mysql_fetch_assoc($chart)) {echo $row['artist']."..." .$row['city']." " .$row['country']. " <span style='foo'>" .$row['total']." USD</span><br>";} Quote Link to comment Share on other sites More sharing options...
Morris2 Posted October 11, 2011 Author Share Posted October 11, 2011 I tried it now, thanks. It dosn't work ... I have this code: while($row = mysql_fetch_assoc($chart)) {echo $row['artist']."..." .$row['city']." " .$row['country']." " "<span style='bigHitList'>".$row['total']." USD</span>"; I placed the below code in the css file: .bigHitList { font-size: 18px; color: yellow; } The browser writes: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' What am I doing wrong? Quote Link to comment Share on other sites More sharing options...
Morris2 Posted October 11, 2011 Author Share Posted October 11, 2011 OK. Now this is working as a stand-alone-script on my server, together with a stand-alone-css file: while($row = mysql_fetch_array($chart)) {echo $row['artist']."..." .$row['city']." " .$row['country']. " <span class='bigHitList'>".$row['total']." USD</span><br>";} GREAT! - thank you so much! Now I added this script to my Joomla 1.7 site, and here it shows right, but dosn't get styled. Where exactly should I insert the CSS file in the Joomla style sheet? Or where do I upload my own stylesheet? (I've tried the edit.css and the template.css files in my template folder without luck) Best regards Morris Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted October 12, 2011 Share Posted October 12, 2011 as I have only used Joomla for a brief time, I really cannot remember.. however if you look at a view source of your page to see which css files are linked to that page, inserting the class styling in any one of those css files should work. Quote Link to comment 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.