Pour une raison quelconque, ma boucle for ne commence pas par l'apparence qu'il semble. Je l'ai testé en plaçant une déclaration d'écho à l'intérieur et il ne s'affiche pas, donc il doit y avoir quelque chose de mal, peut-être ma syntaxe, mais je ne peux pas le voir après avoir regardé pendant des heures.PHP pour la boucle ne pas entrer dans la boucle
Merci pour votre temps.
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);
Et les réponses viennent inondation –