Advertisement

09.04.2008 at 10:36AM PDT, ID: 23703569
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.3

Set bg color to variable

Asked by walker6o9 in PHP Scripting Language, Hypertext Markup Language (HTML)

Tags:

Currently, I have the bg color manually set on line 53.  I would like it if I could set a variable at the top of my code and have that be equal to the bg color on line 1 (thus would make it easier and more obvious to change for a total noob)Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
<?php
 $bg = "336633";
$SCRIPT_NAME=$SERVER_VARS['PHP_SELF'];
$pic=$HTTP_GET_VARS['pic'];
 
$handle=opendir('.');
 
$pics=array();
$count=0;
 
 
while (($file = readdir($handle))!==false) {
                
        if (substr($file,-4) == ".jpg" || substr($file,-4) == ".gif" || substr($file,-4) == ".png" || substr($file,-4) == ".JPG" || substr($file,-4) == ".GIF" || substr($file,-4) == ".PNG"){
        
                $pics[$count] = $file;
                $count++;
        
        }
}
closedir($handle); 
 
 
sort($pics);
reset($pics);
 
 
$nextpicindex = (array_search($pic, $pics) + 1) % count($pics);
$nextpic = $pics[$nextpicindex]; 
// check to see if $pic is populated
// if not, and $pics has some filenames, set $pic to the first one
if (!$pic && (count($pics)>0)) { $pic=$pics[0]; }
 
 $name="";
//      if there is already a pic selected...
if ($pic && !preg_match("/javascript/",$pic)){
      //      if the text should be displayed
            // Capitalize filename for display andf print it
            $name=ucfirst(substr($pic,0,-4));
 }
 ?>
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 
<html>
<head>
<title><?php echo "Image: ".$name."    Number: ". ($nextpicindex==0?sizeof($pics):$nextpicindex)."/".sizeof($pics);?></title>
</head>
<body style="padding:0; margin:0; background:right; background-color:#0000FF; float:none " >
 
<?php
//	if there is already a pic selected...
if ($pic && !preg_match("/javascript/",$pic)){
	//	if the text should be displayed
		// Capitalize filename for display andf print it
		$name=ucfirst(substr($pic,0,-4));
	
	
	echo"<a href=\"?pic=" . urlencode($nextpic) . "\"><img src=\"".$pic."\" style = \"border:0; margin:0; padding:0 align:center\" alt=\"".$name."\" /></a><br /><br />";
 
	}
	
		for ($f=0;$f<=sizeof($pics)-1;$f++){if ($pic==$pics[$f]){$selected = $f+1;}}
 
	echo "\t\t<!-- dropdown -->\n\t\t<form name=\"mainform\" style=\"margin:0; padding:0\">\n\t\t\t<select name=\"pic\">\n";
	//	loop over all pics
	for ($f=0;$f<=sizeof($pics)-1;$f++){
		//	Capitalize filename for display
		$name=ucfirst(substr($pics[$f],0,-4));
		// if the pic is the selected one set selected status
		if ($pic==$pics[$f]){echo "\t\t\t\t<option value=\"".$pics[$f]."\" selected>".$name."</option>\n";}
		//	or simply render another option
		else{echo "\t\t\t\t<option value=\"".$pics[$f]."\">".$name."</option>\n";}
		}
	// close select statement and display show button with predefined text.
	echo "\t\t\t</select>\n\t\t\t<input type=\"submit\" value=\"show\" style=\"height:20; padding:0 0 0 15; margin:0\">\n\t\t</form>\n\t\t<!-- end dropdown --><p />";
 
	
?>
</body>
</html>
[+][-]09.04.2008 at 10:49AM PDT, ID: 22390391

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.04.2008 at 10:49AM PDT, ID: 22390398

View this solution now by starting your 14-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PHP Scripting Language, Hypertext Markup Language (HTML)
Tags: php, html
Sign Up Now!
Solution Provided By: hielo
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20081112-EE-VQP-43 / EE_QW_2_20070628