Trium918 Posted June 14, 2007 Share Posted June 14, 2007 Is it possible to use php and css together. Ok, I am trying to change the background of the html page. I can change the color, but how would I insert an image? <?php // input for background color $background = $_POST['background']; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Edit Background</title> </head> <?php echo "<body bgcolor=\"$background\">"; ?> <form method="post" action="change_background.php"> <table border="1" align="center"> <tr> <td align="center"> <input type="text" name="background" /><br /> <input type="submit" name="submit" value="Change Background"/> </td> </tr> </table> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/55614-solved-php-css-question/ Share on other sites More sharing options...
Caesar Posted June 14, 2007 Share Posted June 14, 2007 I don't see any reference to CSS in there but yeah, using CSS on HTML that has been generated by PHP is well, just the same as using it in a normal HTML page. You can even make it dynamic or database drive. As far as displaying an image...can you be more specific? Quote Link to comment https://forums.phpfreaks.com/topic/55614-solved-php-css-question/#findComment-274801 Share on other sites More sharing options...
Caesar Posted June 14, 2007 Share Posted June 14, 2007 <?php echo' <style type="text/css"> body {background-color: #000000; background-image: url(\'images/bg_img.jpg\');} </style>'; ?> Is that what you're asking? *confused* And you can also call an external stylesheet of course. Quote Link to comment https://forums.phpfreaks.com/topic/55614-solved-php-css-question/#findComment-274804 Share on other sites More sharing options...
Trium918 Posted June 14, 2007 Author Share Posted June 14, 2007 I don't see any reference to CSS in there but yeah, using CSS on HTML that has been generated by PHP is well, just the same as using it in a normal HTML page. You can even make it dynamic or database drive. As far as displaying an image...can you be more specific? No, there is no CSS with in the code I provided. There were no CSS needed. I am sure CSS will be needed to change the background to an image. For instance: body{ background-image:url(image) } I was wondering how can I use the code that I provided in my first post to change the background so that an image is displayed instead. Do you follow me? Note: By using a form that is submitted to the php engine. Quote Link to comment https://forums.phpfreaks.com/topic/55614-solved-php-css-question/#findComment-274806 Share on other sites More sharing options...
Caesar Posted June 14, 2007 Share Posted June 14, 2007 <?php $bgimg = $_POST['bgimg']; $bgcolor = $_POST['bgcolor']; $tablebg = $_POST['tablebg']; echo' <style type="text/css"> body {background-color: #'.$bgcolor.'; background-image: url(\''.$bgimg.'\');} table {background-color: #'.$tablebg.'; } </style>'; ?> Something like that? Quote Link to comment https://forums.phpfreaks.com/topic/55614-solved-php-css-question/#findComment-274810 Share on other sites More sharing options...
Trium918 Posted June 14, 2007 Author Share Posted June 14, 2007 <?php $bgimg = $_POST['bgimg']; $bgcolor = $_POST['bgcolor']; $tablebg = $_POST['tablebg']; echo' <style type="text/css"> body {background-color: #'.$bgcolor.'; background-image: url(\''.$bgimg.'\');} table {background-color: #'.$tablebg.'; } </style>'; ?> Something like that? That is it. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/55614-solved-php-css-question/#findComment-274811 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.