Hi hope to get some help with php :)

hi first im i am a new member here i just registred but i hope to get some help, i hope my english is understandable and readable :).

i want to make a clean php website with out any html… i have tried to search the internet and i havent being able to find the resolved part for my issue ,

i have a folder called css. and a file there called style.css how to i get my index.php to load it so the color and stuff is viewable ?

i tried include (‘css/style.css’);
@import any mant other stuff yes i have installed php5 and php pear if that got some thing to do with i have my own server at home so if i need some thing else installed let me know i am also new at this php i am starting from scratch i am how ever some years ago used to play abit with php .

i hope some will be kind to help me resolve my problem thanks alot in advance , i hope that i posted this the right place here …

my current php
<?php
include(‘css/style.css’);

?>

That’s not possible. The output of the php script has to be a HTML/CSS page, otherwise how will your browser be able to display it?

thats kinda lame since php is one of the greater things that happend since html .

why shouldent it be possible . ? type some thing code , include funtion css display public ?

Well you have the idea of PHP a little backward. PHP is server side, there still must be a client side language that tells the browser what to display. Think of PHP as the prep work for HTML. You COULD do something like this, but its just silly…


<?php
$css = file_get_contents('style.css');
echo "<html><style>$css</style></html>";

As guido2004 says you need html otherwise you will just have an empty page.

Have you viewed the source of a php page?

A definition of css:

Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation semantics (the look and formatting) of a document written in a markup language. Its most common application is to style web pages written in HTML and XHTML, but the language can also be applied to any kind of XML document, including plain XML, SVG and XUL.

hmm how do i then type background color text and link color isent it , pg=background-Color some thing like that in php ?

Again, this is part of HTML / CSS, not PHP (or any other server side language)

Example of when to use PHP: I need to access a database, do number / string comparisons and manipulations, determine what color to make the background based on a user preference.
When to use HTML / CSS: Display text, color and images to the user.

Here’s an example of your background question, I’ll display a random text color for a sentence in a web page.

index.php


<html>
<body>
<?php 
if(rand(0,1)) {
    echo "<p style="color: #0000FF">This sentence is blue</p>";
} else {
    echo "<p style="color: #FF0000">This sentence is red</p>";
}
?>
</body>
</html>

Now what this script does is picks a random number between 1 and 0, and if 1 (true) it will print blue, else it will print red. When the web page is opened up and you view source (right click in a page and view page source) you will only see the html portion:

<html>
<body>
<p style="color: #FF0000">This sentence is red</p>
</body>
</html>

The end user will never be able to view server side code, it is executed before being sent in the form of HTML. It is the CSS property of “color” that defines the text color. Does this clear some things up?

your code is my life saver it is working ! thank you so much and all for the help (;

i do have a domain for my website but i rather post my ip for it instead so you can see http://91.100.5.93

i also happend to have a nother question i have a created a mysql database how to i do so it can load my css :smiley: ? i want to learn basic things i guess i know i can read i just think its more interresting asking people who know about this

Well, your database typically wont be used to store your css file…

Why don’t you try making a simple webpage with CSS / HTML (forget PHP and MySQL) and see what happens. :slight_smile:

ive ben there and done that i think its jsut bored and for my site i learn more :slight_smile:

Alright then. Why is it you thnk you need to load your css files to a db? This is not a common practice at all. What is common practice is using a db to store user credentials, page content (this allows you to develop a single html / php file and then retrieve the page content from a db. What functionaility would you like to try to create for your first project? User login? Poll? Content Management System?