PDA

View Full Version : new banner each time php


textahead
03-07-2009, 03:12 AM
total newbie so please be gentle
Im trying to make a way of displaying a differnet banner depending on how many pages the visitor has been to ie; if this is the 3rd page ive visited so far i want to display banner number (include banner3.php) 3
heres a smplaer if what ive been trying with no success
<?php
if ($freeb == 0) $fb='fb00.php' ;
if ($freeb == 1) $fb='fb01.php' ;
if ($freeb == 2) $fb='fb02.php' ;
if ($freeb == 3) $fb='fb03.php' ;
if ($freeb == 4) $fb='fb04.php' ;
if ($freeb == 5) $fb='fb05.php' ;
include($fb) ;
?>
<?php $freeb++;
?>

so far ive got it to display either banner fb00.php once or the same fb00.php 6 times

cocoonfx
03-07-2009, 07:41 AM
Not sure how to do that, and i don't understand why you want to do that but here is the php to random select data from a MySQL table every time you visit a page.

<?PHP
// row[0] now contains the number of rows in the table

$rand = rand(0,$row[0]);

$query=mysql_query("SELECT * FROM tips where tip_id = '$rand'");
$row= mysql_fetch_object($query);
//replace text with which field you want to echo

echo <?PHP echo ($row->tip); ?>

davidj
03-07-2009, 08:07 AM
you need to write a function which counts pages and include it

if you increment a count every time you hit a page then you can determin how many pages the user has visited

$count = $count + 1;

textahead
03-07-2009, 09:19 PM
Thanks for your help sofar
Cocoon. My reason for wanting to do this is so that I get a new banner on each page. I am part of a banner exchange program and the system works on how many NEW banners are displayed to the visitor. If the same banner is displayed on each page I get a hit count of 1 even if they have visited 10 pages. if I have a different banner on each page i get a count acording to how many pages they have visited
David J
Thanks, I realise that I need to set up a counter. I am now on the trail of sessions. So far I have been working on this for 3 days without success but im sure i willl get there eventualy and all will be happy:)

textahead
03-08-2009, 10:43 AM
Thanks for all your help. Ive figured it out. didnt realise you needed session_start(); on each page till i stumbled across it in an online document. Thanks lots specially Dgreenhouse. Cheers mate