Tema: Css + php?
Ver Mensaje Individual
  #6 (permalink)  
Antiguo 03/10/2010, 18:59
Darcowld
 
Fecha de Ingreso: enero-2009
Mensajes: 27
Antigüedad: 15 años, 3 meses
Puntos: 0
Respuesta: Css + php?

Cita:
Iniciado por mariomon17 Ver Mensaje
Codigo PHP que deberias poner:
Código PHP:
Ver original
  1. <?php
  2. $URL = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] ;
  3.  if ($URL ==  "http://URLWEB/SUBDIRECTORIO/") {
  4. $background = "../bg-web2.jpg";}
  5.  else {$background = "../bg-web.jpg";} ?>
Esto lo pones arriba de la pagina para que siempre lo compruebe, y esto en el head:

Código HTML:
Ver original
  1. <style type="text/css">
  2. body {background: url('<?php echo $background; ?>') repeat-x; }


Entendistes?

Me parece una respuesta exelente, la pude entender bien y parece bueno el concepto :P . Pero me tire el error:
Cita:
Parse error: syntax error, unexpected '?' in /home/musicade/public_html/pruebaloca/header.php on line 52

El codigo del header es este (no todo, pero contiene lo q me pasaste)

Código:
<?php
$URL = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] ;
 if ($URL ==  "http://URLWEB/SUBDIRECTORIO/") {
$background = "../bg-web2.jpg";}
 else {$background = "../bg-web.jpg";} ?>


<?php
include($_SERVER['DOCUMENT_ROOT'].'/includes/configuracion.php');
include($_SERVER['DOCUMENT_ROOT'].'/includes/funciones.php');
include($_SERVER['DOCUMENT_ROOT'].'/session.php');
require "includes/class_db_mysql.php";
$db=new database;
$db->connect();
$key = $_SESSION['id'];
$direccion = explode("/", $_SERVER['REQUEST_URI']);
$naci = time();
if($_SESSION['id']!=null){
$IP = ($_SERVER['HTTP_X_FORWARDED_FOR'])
    ?  $_SERVER['HTTP_X_FORWARDED_FOR']
    :  $_SERVER['REMOTE_ADDR'];
$db->query("UPDATE usuarios SET ultimaaccion=unix_timestamp(), ultimaip='$IP' WHERE id='{$key}'");
$sqlrango=$db->query("SELECT * FROM usuarios WHERE id='{$key}'");
$rangoz=$db->fetch_array($sqlrango);
actualizarango($_SESSION['id'], $rangoz['rango'], $rangoz['puntos']);
}

$sql = "SELECT id, elim, id_autor, titulo, contenido, privado, coments, tags, categoria FROM posts where id='$id'";
$rs = mysql_query($sql, $con);
$row = mysql_fetch_array($rs);

$sql3 = "SELECT * FROM usuarios where id='{$row['id_autor']}'";
$rs1 = mysql_query($sql3, $con);
$raw = mysql_fetch_array($rs1);

$sql1 = "SELECT * FROM usuarios WHERE id='{$key}'";
$rs = mysql_query($sql1, $con);
$rowNot = mysql_fetch_array($rs);

function cabecera_index()
{
	global $comunidad, $descripcion, $titulo, $url, $images, $rangoz, $naci, $db;
echo'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html version="XHTML+RDFa 1.0"  xmlns="http://www.w3.org/1999/xhtml" lang="es" xml:lang="es" >
<head profile="http://purl.org/NET/erdf/profile">




<style type="text/css">
body {background: #16185d url('<?php echo $background; ?>') repeat-x;  }
</style>





  <!--[if IE 6]>
  <script src="'.$images.'/images/js/DD_belatedPNG_0.0.8a-min.js"></script>
  <script>DD_belatedPNG.fix(\'#logo a,li, li a, .systemicons, .categoriaPost,.thumb-clima\');</script>
  <![endif]-->

	<meta http-equiv="X-UA-Compatible" content="chrome=1" />
	<link rel="schema.dc" href="http://purl.org/dc/elements/1.1/" />
	<link rel="schema.foaf" href="http://xmlns.com/foaf/0.1/" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv=\'refresh\' content=\'600\' />
(y despues sigue un monton :P)

No deberia andar bien ? :S