Newbie Problem with a 'while do' loop

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
User avatar
determined
New php-forum User
New php-forum User
Posts: 20
Joined: Sun Sep 28, 2003 12:19 pm
Location: Table Arizona
Contact:

Tue Nov 25, 2003 3:45 pm

There are a few problems that I see:
First there is not an ending "}" on the for loop and the do..while loop.

Second there is a ")" missing after isset(), remember to close all brackets, even if it means there will be a ")" right after a ")". You can see this in my example below.

Third you are trying to get $atrib1 out of $atrib.$i and It is not working. Unfortunately I cant seem to get it to work either, so I changed the way your variables are set up; rather than each value having its own variable, I put the values into an array, that can be called like this $array[1], $array[2], etc.

I have made some changes and tested it to make sure it works. This is what I got:

Code: Select all

<?php 

for ($i=1;$i<7;$i++) {
   $atrib[$i] = "Y";
}
$i=1;
//sets up a counter for the loop
   for ($i=1;$i<12;$i++) {
      if (!isset($atrib[$i])) {
      $atrib[$i] = "N";
      } else {
         $i++;
      }
   }

for ($i=1;$i<12;$i++) {
   print $i . ': ' . $atrib[$i] . '<br>';
}

?>


I hope that takes care of the problem. I will be looking around for how to get add a variable to another variables name. If anyone else could clear this up I would be very appreciative.

- Determined



"If I only had an hour to chop down a tree, I would spend the first 45 minutes sharpening my axe" -- Abraham Lincoln


User avatar
yK
New php-forum User
New php-forum User
Posts: 28
Joined: Tue Aug 19, 2003 1:27 pm

Tue Nov 25, 2003 5:38 pm


Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 6 guests