Posted by brephophagist on 10/26/06 19:34
Seems like you should change $number here:
> elseif ($question_count < $number) {
> $status = "_blank";
> }
>
> elseif ($question_count > $number) {
> $status = "";
> }
to some fixed question count you want to use to determine whether the
button should be "inactive" or not.
i.e.
$question_count = "3";
$question_id = "2";
$count_inactive_threshold = "2";
foreach (range(1, 5) as $number) {
if ($question_id == $number) {
$status = "_selected";
}
elseif ($question_count < $count_inactive_threshold) {
$status = "_blank";
}
elseif ($question_count >= $count_inactive_threshold) {
$status = "";
}
echo "q" . $number . $status . ".gif<br>";
}
You're comparing a variable that doesn't change in the loop against
your iterator... from your description "based
on the count of questions in a database" it seems you should be
comparing a constant / unchanging variable against another variable
pulled from the database.
HTH--
jason
Navigation:
[Reply to this message]
|