|
Posted by Rik on 10/26/06 19:38
stat_holyday@hotmail.com wrote:
> Greetings. I'm confused. I'm attemting to create dynamic buttons based
> on the count of questions in a database. The button has 3 states,
> blank, selected, and inactive. The script below works great, but with
> a strange bug that seems impossible to me.
>
> When the $question_count and $question_id are 2 or more values apart
> the script works, but when they are only 1 value apart, it bugs out.
>
> $question_count = "4";
> $question_id = "3";
>
> Output:
> q1.gif
> q2.gif
> q3_selected.gif
> q4_selected.gif <--- WTF
> q5_blank.gif
Ahum, it's not advisable to have a sig-seperator in your post
(--(space)(newline)), as it will automatically trimmed out by correct
newsreaders.
To answer your question: You set $status isn't set when ($question_id !=
$number && $question_count == $number), and $status will be like the last
status from the last loop (hence doubling the selected in this case.
Either start with an uncoditional $status=''; in your loop, or use:
.....
elseif ($question_count <= $number) {
$status = "_blank";
}
.....
--
Rik Wasmus
[Back to original message]
|