Forum Moderators: coopster

Message Too Old, No Replies

how to work correct with php and css?

         

Superbuis1

2:14 pm on Mar 5, 2004 (gmt 0)

10+ Year Member



Hello!

I finished with the layout of my pages using css. The idea is that after loggin into the system, you will see this page: <snip>

The question I now run into is how to use css with php? I've red some things in this forum that it will work, but it's not all clear to me how exacly. For example the use of include or just <link rel="StyleSheet" type="text/css" href="beststyl.css"/>. And is it possible to just write php code between the css divs? Will css interpret this as 'normal' xhtml. For example my input fields have some layout properties (like borderstyle, font-size, etc). will this work if I 'echo' this in php? (Because these get a value from a xml file)

I hope that my question is clear enough.....

Regards,
Jacco

[edited by: jatar_k at 7:38 pm (utc) on Mar. 5, 2004]
[edit reason] no personal urls thanks [/edit]

PatomaS

2:43 pm on Mar 5, 2004 (gmt 0)

10+ Year Member



Well i'm not so sure about your question, but i'll try to answer it

;)

When yo write a page in php, perl and this kind of languages, you use some commands to "write" the html page in the browser once all the information is together, i mean, tags, information from databases, etc, so in the same way yo write some code like this (just an example)

write("<html>")
write("<head>")
write("<title>Losadres selecteren</title>")
...

you can write another line like this one:

write("<link rel='stylesheet' href='your_style.css' type='text/css' />")

There is no problem about write code beteween the div tags, but you have to be careful with the comiles, values, names, tags and all the things of a normal xhtml page.

You talk about an xml file... what gets the value from it? the input files? If the answer is yes, there is no problem about

Hope it helps, but i think you are in the right way by your own

:)

Superbuis1

3:02 pm on Mar 5, 2004 (gmt 0)

10+ Year Member



Thank you PatomaS!

So it basically means that I have to put 'echo' in front of each line in my (old) html file? So this implies that no real html will be left in my php file... Everything will be managed by the php server... Sounds fine to me, but I wonder why it is possible to write php and html in one file. (Just a general thought) :)

And yes, I'm planning to write php code that will parse data from xml and put it in the responsible input fields...

Regards,
Jacco

Bigjohn

3:30 pm on Mar 5, 2004 (gmt 0)

10+ Year Member



super -

No, you dont.

Here is my head.inc file:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<head>
<title>McDonough Fine Arts - Welcome</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1" >
<META name="KEYWORDS" Content="fine art, mcdonough, mcdonough fine art, art prints, art maps, antique prints, antique maps" >
<META name="description" content="McDonough Fine Art, dealers in antiquarian prints, books, and maps" >
<META name="KEYWORDS" content="audubon prints, ornithological art, gould prints, old maps, fine art prints, native american prints, kinney hall prints">
<META name="robots" content="NOARCHIVE">
<META name="robots" content="INDEX,FOLLOW">

<link rel="stylesheet" type="text/css" href="css/menus.css" >
<script language="javascript" src="popwin.js" type="text/javascript">
</script>
</head>

This is placed in every page by:
require 'head.inc';

within the PHP, like so in my index.php file:


<?php
require 'head.inc';
if (isset($_GET['class'])) {
$class="";
}
include 'containers.inc';
if (!isset($_GET['page'])) {$content= 'page1.inc';}
else {$content= $_GET['page'];}

include $content;
include 'footer.inc';
?>

Does that help?

Superbuis1

4:05 pm on Mar 5, 2004 (gmt 0)

10+ Year Member



Hi,

Thanks. Learning step by step here :) Perhaps that will help, but I'm missing the big picture here. How does your <body> look like in this case for example?

In html my pages are in general build like this:
<body>
<div header>
<div content>
<some smaller divs>
<div footer>

How should I translate/merge this to php?

Regards,
Jacco

volatilegx

4:09 pm on Mar 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Super, I think this is what you're looking for... here's a sample PHP document:

<html>
<head>
<title>Sample PHP Document</title>
<link rel="StyleSheet" type="text/css" href="beststyl.css"/>
</head>
<body>

<?php
# the above tag starts processing PHP commands
# doing some php stuff here
echo "<p>Hello World!</p>\n";
# the tag below ends the processing
# of PHP commands
?>

</body>
</html>

It really doesn't matter how you apply CSS in relation to PHP. All PHP processing happens before the web page comes to the browser, and it's the browser that handles the CSS code... so as long as your PHP code is syntax-error free, then the CSS should work if it is linked, embedded, or in-line.

Superbuis1

4:38 pm on Mar 5, 2004 (gmt 0)

10+ Year Member



That's correct volatilegx! This was already what I thought from the beginning. :) Then I've one question left (at this moment:)). For example I have all my php code at the beginning of my file (like you sad). How can I put a value returned by php (from xml) in for example an input field. I assume that I can use the name property, like name=$aname. But how can I call this variable from php....

regards,
Jacco

theriddla1019

5:00 pm on Mar 5, 2004 (gmt 0)

10+ Year Member



Im guessing you are just wanting to display the php variable within the html of the document. If this is the case do this.

<?=$varname?>

Use the <? and?> to open close php(as im sure you know)

= also is a way to 'echo' the variable

and then the variable name

you can also do this with an array stored in row by:

<?= Row['varname']?>

An example of an input field would be

<input name="DateLocked" maxlength=255 size=21 type="text" value="<?=$DateLocked?>">

Href:

<a href="blah_blah.php?BlahID=<?=$BlahID?>&BlehID=<?=$BlehID?>">

Etc Etc

Hope this helped :)

Superbuis1

5:18 pm on Mar 5, 2004 (gmt 0)

10+ Year Member



Thanks theriddla1019! This was just the answer I was looking for....