Well i need to change my banner of the website alternatively , like once user experiences
the pic1 which would be incorporated in my CSS. But the point is i want that pic to change .
for example
when user 1st time logs in , he see pic1 as a banner and next time or for other user , he might see a different banner ex pic2 . so in a given set of pics pic1 , pic2 , pic3 as banners , the banner keeps changing .

well i am not able to think on how to proceed since the banner link is in my CSS . have no idea on how to collaborate CSS + PHP

Recommended Answers

All 3 Replies

Member Avatar for rajarajan2017

Logic:

i) Generating a random numbers(1-10) between no of images (EX:pic1,pic2,pic3...pic10)
ii) Use the echo "<img src='"."pic".random(1-10)."'/>" in php
iii) Now it will generate different images on every refresh.

to have php in your 'style.css' file is not difficult,
rename style.css style.css.php
link to it as <link rel="stylesheet" type="text/css" href="/style.css.php"> first line of style.css.php <?php header ('content-type:text/css'); ?> file will be parsed as php but outphut as css, then you can use any php to rotate the image in body { background :url(<?php image rotator ?>); } or do anythinbg else to the css you want on the server, the stylesheet downloaded will remain in the .tif for the duration of the seesion but be refreshed on next login, with a different background

firstly sorry for late reply , i didnt get any notification in my mail that someone has replied ( usually never happens ) .
I will try both the techniques , i appreciate both of you . for ur help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.