Results 1 to 7 of 7
Hybrid View
-
28th Sep 2012, 09:57 AM #1OPMember
how implement css in php
am currently doing a project in php,but i dont know how to implement css in php,can anybody help me?
rashid Reviewed by rashid on . how implement css in php am currently doing a project in php,but i dont know how to implement css in php,can anybody help me? Rating: 5
-
28th Sep 2012, 04:15 PM #2MemberWebsite's:
sborg.usNo wait, what?
CSS => used in HTML.
PHP => Server side script, won't be shown to the user unless you embed HTML code in it.
You may wanna check this link: http://www.johnhaydon.com/2011/03/wh...-css-html-php/
V3g3ta | Halcyon | Abhi
-
29th Sep 2012, 01:14 PM #3MemberWebsite's:
somik.org sborg.us
-
29th Sep 2012, 04:48 PM #4Respected Member
Very bad example somik. Also Halcyon was correct in what he said.
Here is a proper example ..
PHP Code:<?php
echo <<<HTML
<html>
<head>
<style>
a { display: block; }
p { display: inline; }
</style>
</head>
<body>
<h2>CSS Display</h2>
<a href="http://www.tizag.com/" target="_blank" class="disp1">Tizag.com - Learn to Whip the Web</a>
<a href="http://www.tizag.com/" target="_blank" class="disp1">Tizag.com - Learn to Whip the Web</a>
<a href="http://www.tizag.com/" target="_blank" class="disp1">Tizag.com - Learn to Whip the Web</a>
<a href="http://www.tizag.com/" target="_blank" class="disp1">Tizag.com - Learn to Whip the Web</a>
<a href="http://www.tizag.com/" target="_blank" class="disp1">Tizag.com - Learn to Whip the Web</a>
<br />
<p class="disp1">These paragraph </p>
<p class="disp1">elements </p>
<p class="disp1">have been </p>
<p class="disp1">inlined.</p>
</body>
</html>
HTML;
?>
-
30th Sep 2012, 12:41 AM #5MemberWebsite's:
somik.org sborg.usLOL!
Okies, so this is how i usually write the codes:
PHP Code:<?php
/**
* @author Somik
* @copyright 2012
*/
// main PHP codes goes here
setcookie("test",$testvalue);
?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html" />
<meta name="author" content="Somik" />
<title>Untitled 2</title>
<style type="text/css">
body{
background-color: black;
background-image: url(/path/to/image.jpg);
}
.tbl_main{
border: 0px;
border-collapse: collapse;
}
</style>
<script type="text/javascript">
// Javascript goes here
</script>
</head>
<body>
<table class="tbl_main">
<tr>
<td>
<?php echo $value[1]; ?>
</td>
<td>
<?php echo $value[1]; ?>
</td>
</tr>
<tr>
<td colspan="2">
<?php myfunction($data1, $data2); ?>
</td>
</tr>
</table>
</body>
</html>
<?php
// PHP functions goes here
function myfunction($data1, $data2){
echo $data1 + $data2;
}
?>
Yes, you can break the php codes with ?> and write HTML, CSS, javascript and whatever you need. Then when you need PHP again, just put it in between PHP tags <?php and ?>
Follow instructions on this site for more info: http://www.tizag.com/phpT/
-
30th Sep 2012, 05:36 AM #6MemberWebsite's:
sborg.us
No wonder why I end up in a mess whenever I see your codes!
It is a good practice to separate the html and the server side activities. Coz the user doesn't need to know what happens when he/she loads a page!
MVC pattern (en.wikipedia.org/wiki/Model?view?controller) was introduced to take care of this in the first place.
P.S: You need not introduce MVC concepts in a small application (or script) but it may help you out in the long run
V3g3ta | Halcyon | Abhi
-
29th Sep 2012, 04:49 PM #7Member
You would be best of trying to use some kind of templating system. Then you can separate the two.
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
[Hiring] Want someone to implement a video-section
By wraum in forum Completed TransactionsReplies: 2Last Post: 8th Oct 2011, 10:05 PM -
How to implement CPA Lead on vbulletin?
By adanrott in forum Webmasters, Money MakingReplies: 4Last Post: 26th Oct 2010, 03:57 AM -
How to implement referral system ?
By arunkumar2006 in forum phpBBReplies: 2Last Post: 15th Jun 2008, 04:14 PM
themaCreator - create posts from...
Version 3.24 released. Open older version (or...