I have created a website which works well on the desktop, but on iPhone and iPad background images are not shown.
I have tried deleting the php script that chooses the image and re-written the code to use javascript to set the background and in this case the background is showed correctly.
This is the php code that chooses the image:
<?php
//if doesn't exist, open the session
if(!isset($_SESSION))
{
session_start();
}
//set coockie
setcookie("allweb","connected", time()+3600);
//if doesn' exist yet, I create a new array
if(!isset($_SESSION['arrayImage'])){
$arrayImage = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
}else{// else I get from sessiom
$arrayImage = $_SESSION['arrayImage'];
}
//if already exist variable $picture, increment it
if(isset($_SESSION['picture']) && isset($arrayImage)){
$picture=$_SESSION['picture'];
$picture = $picture + 1;
$_SESSION['picture'] = $picture;//save picture
}else{// else I create it
$picture = 1;
$_SESSION['picture'] = $picture;// save it
shuffle($arrayImage);// I shuffle the array
$_SESSION['arrayImage'] = $arrayImage;//save array to the session
}
?>
and in the php pages i have this code between the style tags:
<style type="text/css">
<?php
if($picture < 15){//if I'm not out fo bound I continue
echo 'body {background-image:url("images/bg'.$arrayImage[$picture].'hq.jpg");}';
}
else{// else I set picture to default value and restar the loop.
$picture = 0;
$_SESSION['picture'] = $picture;// save it
echo 'body {background-image:url("images/bg'.$arrayImage[$picture].'hq.jpg");}';
}
?>
</style>
The problem is that the images are not showed immediately but I have to zoom the pages then they appear.