php用不了for循环吗,PHP for循环不进入循环

出于某种原因,我的for循环不是从看起来的外观开始.我通过在其中放置一个echo语句来测试它并且它没有显示所以必须有一些错误,也许我的语法,但我看了几个小时后看不到它.

谢谢你的时间.

echo $completedstaffrows; // value of 5

echo $completedeventrows; //value of 4

echo "
";

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

你想迭代,而我比可变数量少,而不是更多.

标签:php,for-loop,codeigniter

来源: https://codeday.me/bug/20190713/1444778.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值