mattyd Posted October 19, 2010 Share Posted October 19, 2010 Hello. I am interested in taking a result returned from a database and having it displayed in a certain way/style on the user's screen; For example, the user enters text into a field and hits "submit" - the data is saved in the database then displayed to the user (This part I have working just fine so far due to help I received here.) My question is if I would like to, for example, have said text not simply dumped to the top of the screen, inline, but nicely formatted in a boxed, text area, I assume I will use HTML/CSS, and I was wondering if anyone had any good links/tutorials regarding this topic so I may look further into it (my search thus far has not turned up the correct topic or results). Thank-you in advance for any assistance. ~Matty Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted October 19, 2010 Share Posted October 19, 2010 you can integrate PHP into HTML/CSS very easily. here is the content of a file called test.php as an example <html> <head></head> <body> <p>The current second is <span style='font-size:16px;font-weight:bold;color:red;'><?php echo time(); ?></span> on this computer.</p> </body> </html> Quote Link to comment Share on other sites More sharing options...
fortnox007 Posted October 19, 2010 Share Posted October 19, 2010 Hello. I am interested in taking a result returned from a database and having it displayed in a certain way/style on the user's screen; For example, the user enters text into a field and hits "submit" - the data is saved in the database then displayed to the user (This part I have working just fine so far due to help I received here.) My question is if I would like to, for example, have said text not simply dumped to the top of the screen, inline, but nicely formatted in a boxed, text area, I assume I will use HTML/CSS, and I was wondering if anyone had any good links/tutorials regarding this topic so I may look further into it (my search thus far has not turned up the correct topic or results). Thank-you in advance for any assistance. ~Matty I could really recommend to set a class or id with php and use an external stylesheet (instead of what i see very often here in-line style). that way you keep things nicely separated and it's easy to switch styles. But if you rather have in-line style (which sneaky let's you duplicate your code more) the result (view) will be the same for instance a day and night concept: css file could look like this: .night { color: white; background-color: black; } .day{ color: blue; background-color:white; } php code could look like this $time = 'day'; //don't use this of course as a time indicator ;-) $my_array = array(2,4,6,8,10); // just a random array to created some output if ($time == 'day'){ // in case it's day foreach($my_array as $key => $value){ echo '<p class="day">any thing you like can be put inside here ('.$value.')(day) <p>'; } }else{ // in case of night foreach($my_array as $key => $value){ echo '<p class="night">any thing you like can be put inside here ('.$value.')(night) </p>'; } } I haven't tested it but I hope you see the Idea. if not let me know and ill try to clarify more. -edit: i just tested it and it works -edit2: changed the css a bit , they were the same. day now has a white background and blue font color, and night black background white font color Quote Link to comment Share on other sites More sharing options...
fortnox007 Posted October 19, 2010 Share Posted October 19, 2010 notice though my code is a bit redundant, (i did that of course from a teacher perspective lolzors) it would have been better to set a class as variable, Like: if ($time == 'lalala'){ $class = 'day'; }else{ $class = 'night'; }// and put this class var in your loop in the element tag or whatever you want. // like echo '<div class="'.$class.'"> lalalalalala </div>'; that way you only need 1 foreach()-loop instead of 2. Idea of css html and php stays the same though. Nice thing too is that you can sell this to your client in case they have a special event. just make a nice css for it and php does the rest. Quote Link to comment Share on other sites More sharing options...
mattyd Posted October 20, 2010 Author Share Posted October 20, 2010 Thanks for everyone's help and input. ~Matty Quote Link to comment Share on other sites More sharing options...
fortnox007 Posted October 20, 2010 Share Posted October 20, 2010 mark it solved before its too late and the aliens abduct you! :o 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.