Jump to content

CSS by PHP


chaosxkitten

Recommended Posts

I have the hardest time spotting my own errors....

 

I'm writing some CSS that depends on PHP.

 

This is the php created css...


<?php

if (isset($_POST['submitted'])){

//variables from form
  
$bars2 = $_POST['stages'];
   $first2 = $_POST['first'];
   $last2 = $_POST['last'];
    //Separate the rgb values
   $fv = explode(",","$first");
   $lv = explode(",","$last");
    
   //Do some math to figure out the step value
   $n = ($bars - 1);
   $j1 = (($lv["0"] - $fv["0"])/$n);
   $j2 = (($lv["1"] - $fv["1"])/$n);
   $j3 = (($lv["2"] - $fv["2"])/$n);


//Variables and math.

$step = ($bars2 - 2);
$l = "0";
$w = (100 / $bars2);
$r = $fv["0"];
$g = $fv["1"];
$b = $fv["2"];

// gerneral div CSS

echo "div {
position: absolute;
top: 20px;
height: 600px;
}";


//First bar
echo "#start {
position: absolute;
left: $l%;
width: $w%;
background-color: rgb($first2);
}";

//Middle Bars
while ($step != 0){
    $r += $j1;
    $g += $j2;
    $b += $j3;
    $l += $w;
    
    $r2 = round($r);
    $g2 = round($g);
    $b2 = round($b);
    
    echo "#$step {
    position: absolute;
    left: $l%;
    width: $w%;    
    background-color: rgb($r2,$g2,$b2);
    }";
    $step -= 1;
}

$l += $w;

//Last bar
echo "#end {
position: absolute;
left: $l%;
width: $w%;
background-color: rgb($last2);
}";

}
?>

 

 

 

and this is the php that defines the div elements..

 


if (isset($_POST['submitted']))	{

    //variables from form
    $bars = $_POST['stages'];
  
    //Display necessary  div tags
    $div = ($bars - 2);

     echo '<div id="start"></div>';
    
    while ($div != 0){
	echo "<div id='$div'></div>";
	$div -= 1;
    }
    
     echo '<div id="end"></div>';

 

 

and here is the link of where I'm testing it...

 

http://easlnx01.eas.muohio.edu/~meadecm/tvtest.php

 

 

Something is not letting the middle bar divs print, and I can't find the error. My loop seems to work because it adds the correct amount of space in the center.

 

 

Please don't hack me X.X

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.