Dawg;10908459 wrote:I was thinking of having a function with an array containing the url and link for the ad. The function could randomly select an array element for display and generate the html code.
for random, you could do something like,
$ads = array(
1 => array(
'title' => 'add one',
'url' => 'http://fadsfasdf.ca/',
),
2 => array(
'title' => 'add two',
'url' => 'http://vxczvzxc.ca/',
),
3 => array(
'title' => 'add three',
'url' => 'http://rweqrwqe.ca/',
),
);
$victim = rand(1,(count($ads)));
$ad = $ads[$victim];
Dawg;10908459 wrote:If I had a static list of ads and links, how would I use php to start at the top and move down the list on a page refersh?
for toggling through, you could do something like
session_start();
$ads = array(
1 => array(
'title' => 'add one',
'url' => 'http://fadsfasdf.ca/',
),
2 => array(
'title' => 'add two',
'url' => 'http://vxczvzxc.ca/',
),
3 => array(
'title' => 'add three',
'url' => 'http://rweqrwqe.ca/',
),
);
$count = count($ads);
$_SESSION['ad'] = (!isset($_SESSION['ad']) || $_SESSION['ad'] == $count) ? 1 : $_SESSION['ad']+1;
$ad = $ads[$_SESSION['ad']];