sparknlaunch Posted March 17, 2012 Share Posted March 17, 2012 Hi, (Apologies in advance if this is a total newbie question - if it is, just give me some idea on what I need to search for!) I have written php code that essentially pulls together multiple records (using mySQL) and displays them in a webpage. The challenge I have now is making the output pretty. What is the best way to do this? I have my css file (with several styles in the format below): .textstyle0 {font-family:Tahoma;font-weight:normal;font-style:normal;font-size:48px;text-decoration:none;color:#ffffff;} div.Object50 { position:absolute; padding-right:5px; top:189px; left:92px; z-index:0; text-align:left; width:437px; } And my html file (that I want to bring in the php output): <div class="Object50"><span class="textstyle0">Q. THIS IS A TEST?<br></span></div> My php code is sitting in a tidy block: $result = mysql_query("SELECT * FROM tbl_scores WHERE ID=$f_id") or die(mysql_error()); $row = mysql_fetch_array( $result ); $f_score = $row['score']; $f_freq = $row['freq']; echo "test" . $f_score; Do I need to update all my php code with the relevant css tags or can I reference the php? Or do I split up my php code? Do I leave my php code at the top and store all the values somewhere? Then these get pulled into html? I guess I am trying to reduce how much of the php coding I need to modify while leaving the flexibility in the design.... Quote Link to comment https://forums.phpfreaks.com/topic/259159-php-and-css-best-practice/ Share on other sites More sharing options...
guinbRo Posted March 17, 2012 Share Posted March 17, 2012 I'm not quite sure if I'm following what you're asking, but since PHP is going to simply print text, you can style it as you normally would with HTML/CSS. For example: echo'<p id="someDiv">' . $f_score . '</p>'; You could also do something like this: <p id="someDiv"><?php echo $f_score ?></p> Quote Link to comment https://forums.phpfreaks.com/topic/259159-php-and-css-best-practice/#findComment-1328575 Share on other sites More sharing options...
sparknlaunch Posted March 18, 2012 Author Share Posted March 18, 2012 Thanks for the reply. I am looking for the easiest way to retain my php code in one place while adding in formatting. Your second suggestion looks best. This way I can run all processing code at top and simply bring in out put with html at bottom. Quote Link to comment https://forums.phpfreaks.com/topic/259159-php-and-css-best-practice/#findComment-1328706 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.