PHP Question for ..
(1/1)
KellyAX:
-- 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(1, 3);
$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(1, 2);
$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)
DB:
I don't get what you want. Please can you elaborate?
KellyAX:
~.\\.. 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]
DB:
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.
Navigation
Message Index
View Hi-Quality Version of the Current Page