Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6109349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:23:41+00:00 2026-05-23T14:23:41+00:00

For some reason my for loop is not starting by the looks it seems.

  • 0

For some reason my for loop is not starting by the looks it seems. I tested it by placing an echo statement inside it and it does not display so there must be something wrong, maybe my syntax but I cannnot see it after looking at it for hours.

Thanks for your time.

echo $completedstaffrows; // value of 5
        echo $completedeventrows; //value of 4
            echo "<br/>";

        //Staff

            //For loop to enter the correct amount of rows as entered in the form
            for ($i=0; $i > $completedstaffrows; $i++)
            {

                //Data not inserted into Staff table, FK given from dropdown on form to insert in linking table

                $staffdata = array
                (
                    'staff_id' => $this->input->post ('staff'.$i),
                    'procedure_id' => $procedurefk,
                    'quantity' => $this->input->post ('staff_quantity'.$i),
                    'quantity_sterilised' => NULL, //not implemented yet
                );

                $inserthumanresource = $this->db->insert ('hr', $staffdata);
                echo "hello world"; // to test if for loop working
            }



        //Events

                //For loop to enter all events rows completed by user
                for ($i=0; $i > $completedeventrows; $i++)
                {

                    //First input into "Medical Supplies" table
                    $medsupplies = array
                    (
                        'name' => $this->input->post ('supplies'.$i),
                        'manufacturer' => "Bruce Industries" //To be implemented
                    );

                        //Insert data into table
                        $insertmeds = $this->db->insert ('med_item', $insertmeds);

                        //Get med supplies foreign key for linking table
                        $medsuppliesfk = $this->db->insert_id();

                    //Then input into table "Event"

                    $eventdata = array 
                    (
                        'time' => $this->input->post ('time'.$i),
                        'event' => $this->input->post ('event'.$i),
                        'success' => $this->input->post ('success'.$i),
                        'comment' => $this->input->post ('comment'.$i),
                        'procedure_id' => $procedurefk

                    );
                        //Insert
                        $insertevent = $this->db->insert ('procedure_event', $eventdata);


                        //Get event fk for linking table 
                        $eventfk = $this->db->insert_id();

                    //Linking table "Resources"

                    $resourcedata = array
                    (
                        'event_id' => $eventfk,
                        'medical_item_id' => $medsuppliesfk,
                        'quantity' => NULL, //Not implemented yet
                        'unit' => NULL



                    );

                    $insertresource = $this->db->insert ('resources', $resourcedata);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:23:41+00:00Added an answer on May 23, 2026 at 2:23 pm

    change

    for ($i=0; $i > $completedstaffrows; $i++)

    to

    for ($i=0; $i < $completedstaffrows; $i++)

    You want to iterate while i is LESS than the variable amount, not more.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason my outer for loop does not seem to be doing anything,
the following code is very simple, but for some reason, for-loop does not iterate
I'm trying to loop an exception, but for some reason its not giving me
I have a game loop written in Haxe/Flash. For some reason it slows down
For some reason it looks like constructor delegation doesn't work in the following snippet:
For some reason I am not able to use the TextFlow element in WPF.
For some reason, I can not seem to change the default position of an
As the question says, for some reason my program is not flushing the input
The title is self explanatory. For some reason in the loop in int main(),
Theres some reason for this code not reach the first else? I got it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.