Jump to content

php to change background image


conan318

Recommended Posts

Hi i am trying to write a small script to change the background img from my admin small panel i am making im not getting errors nor is the background img  for my content changing. if i echo $background it display the img url correctly. can anyone see what where its going wrong

 

thanks again


$background;
$data = mysql_query("SELECT * from main.background  ORDER BY id DESC LIMIT 1;") or die(mysql_error());
//Puts it into an array 

while($info = mysql_fetch_array( $data )) 
{ 





$background='img/'.$info['img']; // have also tryed  $background="img/".$info['img'];


}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<LINK REL="SHORTCUT ICON" HREF="img/fav.png">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="mb.css" rel="stylesheet" type="text/css" />
<title>Mongrel Bastards</title>


</head>

<body>
<style type="text/css">
.content{

    background-image:url('<?php $background ?>');
height:2500px; width:1008;}



</style>

Link to comment
https://forums.phpfreaks.com/topic/244403-php-to-change-background-image/
Share on other sites

is the style element meant to be in  the head of the document cause i have tryed it there with no luck either.

if i  add the image in css file it works fine. but for some reason i cant embed it. strange

did you try to echo  as showed above??

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.