gpt4 book ai didi

PHP for循环不进入循环

转载 作者:可可西里 更新时间:2023-10-31 23:54:24 24 4
gpt4 key购买 nike

出于某种原因,我的 for 循环看起来并没有开始。我通过在其中放置一个 echo 语句来测试它,但它没有显示,所以一定有问题,也许是我的语法,但我看了几个小时后还是看不到它。

感谢您的宝贵时间。

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);

最佳答案

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

应阅读:

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

或者也许:

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

关于PHP for循环不进入循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6616690/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com