Darren Beige
wonders of the brain ...

Home  Browse Content  Upload Content  Forum  Ssh!  Contact


Pages: [1]   Go Down
Print
Topic: PHP Question for ..  (Read 2553 times)
KellyAX
Newbie


Reputation: +0/-0
Offline Offline

Posts: 6


View Profile Email Awards
« on: July 23, 2009, 10:14:10 AM »

-- I know "THIS" forum clearly isn't the place for PHP questions, but you seem to know what you're doing, so yeah.


I was curious if there was a way to do multiple IF checks in one file.

Code: (#1 -- What I Need--)
<?php

$random 
rand(13);
$color[1] =("FF0000");
$color[2] =("00FF00");
$color[3] =("0000FF");
$useColor =("$color[$random]");

if (
$useColor == FF0000){
$title =(" RED ");
}

if (
$useColor == 00FF00){
$title =(" GREEN ");
}

if (
$useColor == 0000FF){
$title =(" BLUE ");
}

echo 
"<h2 style=\"color:";
echo 
htmlspecialchars($color[$random]);
echo 
";\"> \n"

echo "The Random Color Chosen Was .. ";
echo 
htmlspecialchars($title);
echo 
"</h2>";

?>


Code: (#2 -- What I Have--)
<?php

$random 
rand(12);
$color[1] =("FF0000");
$color[2] =("0000FF");
$useColor =("$color[$random]");

if (
$useColor == FF0000){
$title =(" RED ");
} ELSE {
$title =(" BLUE");
}

echo 
"<h2 style=\"color:";
echo 
htmlspecialchars($color[$random]);
echo 
";\"> \n"

echo "The Random Color Chosen Was .. ";
echo 
htmlspecialchars($title);
echo 
"</h2>";

?>
Code: (-- Commenting --)
<?php 

// If the color found isn't red, it must be blue. You cannot do this three times.

// ^^ #2 Maximum two colors, and from my knowledge you cannot have;
//&#160; &#160; -- ------- --- ------&#160; --- ---- -- --------- --- ------ ----

// IF ($LOREM == $IPSUM){
//&#160; &#160; IF ($DOLOR == $SIT){
//&#160; &#160; &#160; DO FUNCTION();
//&#160; &#160; }
// }

// (check) IF VARI01 == VARI02 (do)
//&#160; &#160;(another check) IF VARI03 == VARI04 (do)
//&#160; &#160; &#160;(do -- something)
//&#160; &#160;(finish doing)
// (finish doing)
« Last Edit: October 11, 2009, 12:53:47 PM by DB » Logged
DB
Administrator
Newbie
*****

Reputation: +1001/-0
Offline Offline

Posts: 36


  • Awards Given to users who post a funny, witty or clever post or comment to Darren Beige

  • View Profile WWW Email Awards
    « Reply #1 on: July 23, 2009, 11:23:33 AM »

    I don't get what you want. Please can you elaborate?
    Logged

    KellyAX
    Newbie


    Reputation: +0/-0
    Offline Offline

    Posts: 6


    View Profile Email Awards
    « Reply #2 on: July 24, 2009, 12:49:46 AM »

    ~.\\.. LINK ..//.~

    I was accidentally comparing HEX values with strings, it is all cleared up now and I have my newest crapsterpiece up and running.

    Code: (Something Wrong)
    <?php if ($VARIABLE == 000000){ /* doesn't work */ ?>
    Code: (Something Right)
    <?php if ($VARIABLE == "000000"){ /* does work */ ?>

    [Edited by DB for clarity]
    « Last Edit: September 24, 2009, 06:31:31 PM by DB » Logged
    DB
    Administrator
    Newbie
    *****

    Reputation: +1001/-0
    Offline Offline

    Posts: 36


  • Awards Given to users who post a funny, witty or clever post or comment to Darren Beige

  • View Profile WWW Email Awards
    « Reply #3 on: July 24, 2009, 12:19:19 PM »

    Oh right. Yeah, you wanna be careful of those quote marks. By the way, you could have easily used javascript to change the background colour every 2seconds, which is a much better method than relying on PHP and HTTP-header refreshes.
    Logged

    Advertisement Bot
    Bot

    *

    Reputation: N/A



    Posts: N/A


    View Profile Email
    « Ads by Google»


    Ad Bot
    Pages: [1]   Go Up
    Print
    Jump to: