Advertisement

08.25.2008 at 01:30PM PDT, ID: 23676553
[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!

7.8

Title Display Error

Asked by walker6o9 in PHP Scripting Language

Tags:

I'm using the follow code to create an image displayer.  It says the title of the pages it creates with the name of the image and number its out of.  Example:
Image: date1.jpg    Number: 3/15

The problem is that when it gets to the last image, instead of displaying 15/15, it displays 0/15.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:
82:
83:
84:
85:
86:
87:
88:
89:
<?php
 
 
$SCRIPT_NAME=$SERVER_VARS['PHP_SELF'];
$pic=$HTTP_GET_VARS['pic'];
 
$handle=opendir('.');
 
$pics=array();
$count=0;
$bg="#cccccc";
 
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)."/".sizeof($pics);?></title>
</head>
 
<body>
<?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 "\n\t\t<!-- imagename -->\n\t\t<b>".$name;
		//echo " ".$selected."/".sizeof($pics);
	echo "</b>\n\t\t<!-- imagename end -->\n<p />";
	// Display table with for+next arrows, and a black line around the image
   echo "\t\t<!-- table with image -->\n\t\t<table width=1 border=0 cellspacing=0 cellpadding=1 bgcolor=\"#000000\">\n\t\t\t<tr>\n\t\t\t\t<td bgcolor=\"".$bg."\">";
	
	
		echo"</td>\n\t\t\t\t<td><a href=\"index.php?pic=" . urlencode($nextpic) . "\"><image src=\"".$pic."\" alt=\"".$name."\" border=0></a></td>";
	
	echo"</td>\n\t\t\t</tr>\n\t\t</table>\n\t\t<!-- table with image end -->\n\t\t<!-- Textlinks--->\n\t\t";
}
	
		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\">\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&nbsp;<input type=\"submit\" value=\"show\">\n\t\t</form>\n\t\t<!-- end dropdown --><p />";
 
	
?>
 
</body>
</html>
[+][-]08.25.2008 at 01:34PM PDT, ID: 22309019

View this solution now by starting your 7-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

Zone: PHP Scripting Language
Tags: php
Sign Up Now!
Solution Provided By: hernst42
Participating Experts: 2
Solution Grade: A
 
 
[+][-]08.25.2008 at 01:37PM PDT, ID: 22309040

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.25.2008 at 01:59PM PDT, ID: 22309217

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.25.2008 at 02:11PM PDT, ID: 22309294

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628