par
leo2v » 12 juin 2011, 14:48
Bonjours je suis debutant en PHP / css et je souhaite tester un backgroud qui change en fonction de la page chargée
voici mon code:
header.php:
Code : Tout sélectionner
<?
// extraction du nom de fichier courant, sans extension
$pageName = basename($_SERVER['PHP_SELF'],".php");
// attribution de l'image (et du titre, par la même occasion)
switch($pageName) {
case 'murs': $imagefond = "images/murs.jpg"; $title = "Murs"; break;
case 'sols': $imagefond = "images/sols.jpg"; $title = "Sols"; break;
case 'cuisinnes': $imagefond = "images/bains.jpg"; $title = "Cuisinnes"; break;
case 'realisations': $imagefond = "images/reas.jpg"; $title = "Realisations"; break;
default: $imagefond = "images/index.jpg"; $title = "Accueil"; break;
}
?>
<html><head>
<title><?= $title?></title>
<link type="text/css" rel="stylesheet" href="styles.css">
<style type="text/css">
body { background-image: url("<?= $imagefond?>") }
</style>
</head><body>
styles.css:
index.php:
logiquement mon index.php devrais inclure mon header avec par default l'image et le titre acceuil mais la rien ?????
pourtant je suis bien sous wamp les services sont op etc
help me please
Bonjours je suis debutant en PHP / css et je souhaite tester un backgroud qui change en fonction de la page chargée
voici mon code:
header.php:
[code]<?
// extraction du nom de fichier courant, sans extension
$pageName = basename($_SERVER['PHP_SELF'],".php");
// attribution de l'image (et du titre, par la même occasion)
switch($pageName) {
case 'murs': $imagefond = "images/murs.jpg"; $title = "Murs"; break;
case 'sols': $imagefond = "images/sols.jpg"; $title = "Sols"; break;
case 'cuisinnes': $imagefond = "images/bains.jpg"; $title = "Cuisinnes"; break;
case 'realisations': $imagefond = "images/reas.jpg"; $title = "Realisations"; break;
default: $imagefond = "images/index.jpg"; $title = "Accueil"; break;
}
?>
<html><head>
<title><?= $title?></title>
<link type="text/css" rel="stylesheet" href="styles.css">
<style type="text/css">
body { background-image: url("<?= $imagefond?>") }
</style>
</head><body>[/code]
styles.css:
[code]body { background: #ccc 95% 95% fixed no-repeat }[/code]
index.php:
[code]<? include('header.php'); ?>
<div>index</div>
</body></html>[/code]
logiquement mon index.php devrais inclure mon header avec par default l'image et le titre acceuil mais la rien ?????
pourtant je suis bien sous wamp les services sont op etc
help me please