Jump to content

Random css that are bounded


Bobscrachy

Recommended Posts

My goal is to have a set number of cascading style sheets which randomly execute with a refresh of a webpage. The hitch I'm having is that i want to set the array of css files to be bounded by a certain number of times the page is refreshed. I thought I could do this with just php, but all I'm coming up with is just creating a random css display script without a bound on the number of refreshes.

 

How do I bound it by the number of refreshes?

 

<?php

$sheetx[0] = "black";
$sheetx[1] = "blue";
$sheetx[2] = "blue";
$sheetx[3] = "black";
$sheetx[4] = "blue";
$sheetx[5] = "black";
$sheetx[6] = "red";
$sheetx[7] = "blue";
$sheetx[8] = "red";
$sheetx[9] = "black";

$number = 0;
$minus = 1;
$fifteen = 9;
$css = ".css";

while ($number <=  {
echo "<br>";
$number = $number + 1;
}

$random_number = rand(0,$number);
echo "$random_number";
echo "<br>";
echo "<br>";


echo "http://domain/icons/$sheetx[$random_number]".$css;
?>

 

-Bob

Link to comment
Share on other sites

I know its a syntax error. I'm not familiar with the in and outs of sessions.  :-[

 

<?php
session_start();
$_SESSION['refreshno'] = $_SESSION['refreshno']++;


$sheetx[0] = "black";
$sheetx[1] = "blue";
$sheetx[2] = "blue";
$sheetx[3] = "black";
$sheetx[4] = "blue";
$sheetx[5] = "black";
$sheetx[6] = "red";
$sheetx[7] = "blue";
$sheetx[8] = "red";
$sheetx[9] = "black";

$number = 0;
$minus = 1;
$fifteen = 9;
$css = ".css";

while ($number <=  {
echo "<br>";
$number = $number + 1;
}

$random_number = rand(0,$number);
echo "<br>";
echo "<br>";


if ($_SESSION['refreshno'] > 10)
{
echo "http://domain/icons/$sheetx[$random_number]".$css;
else
$_SESSION['refreshno'] = 1;

echo "refreshno= ". $_SESSION['refreshno']; 
?>

Link to comment
Share on other sites

I've written it, but now there is a different problem. For some reason the variables below line 41 aren't executing. Since its the second part of my while statement the script gives out after 15 refreshes. Do you have any suggestions?

 

<?php
session_start();  
$_SESSION['views'] = $_SESSION['views'] + 1;

if ($_SESSION['views'] < 15)
{

$sheetx[0] = "black";
$sheetx[1] = "blue";
$sheetx[2] = "blue";
$sheetx[3] = "black";
$sheetx[4] = "blue";
$sheetx[5] = "black";
$sheetx[6] = "red";
$sheetx[7] = "blue";
$sheetx[8] = "red";
$sheetx[9] = "black";

$random_text[0] = "TEXT0";
$random_text[1] = "TEXT1";
$random_text[2] = "TEXT2";
$random_text[3] = "TEXT3";
$random_text[4] = "TEXT4";
$random_text[5] = "TEXT5";
$random_text[6] = "TEXT6";
$random_text[7] = "TEXT7";
$random_text[8] = "TEXT8";
$random_text[9] = "TEXT9";
//line 28 

$number = 0 + $_SESSION['views'];
$css = ".css";
if ($number <= 15)
{$random_number = rand(0,$number);
echo "<head>
<link rel=\"stylesheet\" type=\"text/css\" href=\"http://domain/icons/$sheetx[$random_number]$css\"/>
</head>";
echo "$random_text[$random_number]";}

else 
//line 41

{
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"http://bobscrachy.redirectme.net/icons/".$sheetx[2].$css."/></head>";
echo $random_text[2];}

}

else
{
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"http://bobscrachy.redirectme.net/icons/$sheetx[2]$css\"/></head>";
echo $random_text[2];}?>

Link to comment
Share on other sites

Solved

 

Thank you for the help guys.  :)

 

<?php
session_start();  
$_SESSION['views'] = $_SESSION['views'] + 1;

$number = 0 + $_SESSION['views'];
$css = ".css";


$sheetx[0] = "black";
$sheetx[1] = "blue";
$sheetx[2] = "blue";
$sheetx[3] = "black";
$sheetx[4] = "blue";
$sheetx[5] = "black";
$sheetx[6] = "red";
$sheetx[7] = "blue";
$sheetx[8] = "red";
$sheetx[9] = "black";

$random_text[0] = "TEXT0";
$random_text[1] = "TEXT1";
$random_text[2] = "TEXT2";
$random_text[3] = "TEXT3";
$random_text[4] = "TEXT4";
$random_text[5] = "TEXT5";
$random_text[6] = "TEXT6";
$random_text[7] = "TEXT7";
$random_text[8] = "TEXT8";
$random_text[9] = "TEXT9";

if ($number <= 15)

{$random_number = rand(0,$number);
echo "<head>
<link rel=\"stylesheet\" type=\"text/css\" href=\"domain/icons/$sheetx[$random_number]$css\"/>
</head>";
echo "$random_text[$random_number]";}

else 

{
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"domain/icons/" .$sheetx[2] .$css. "/></head>";
echo $random_text[2];}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.