【问题标题】:Placing a bid inside a bids table using codeigniter使用 codeigniter 在出价表中放置出价
【发布时间】:2016-06-01 08:30:21
【问题描述】:

我正在尝试构建一个投标应用程序。我想将一个文本字段与输出行的主键相关联。例如 textfield 是 bid_amount 。当您输入投标金额时,我希望输入的bid_amount 以及投标人(truckerid)和投标的产品(luggage_id)存储在投标表中。要投标的输出产品存储在另一个表(寄售表)中。下面是我的模型、视图和控制器。

以下是出现的错误

发生数据库错误

Error Number: 1054
Unknown column 'Array' in 'field list'
UPDATE `bids` SET `luggage_id` = NULL, `bid_amount` = Array, `truckerid` = '84K7B7'
Filename: models/Truckeraccount_model.php
Line Number: 129

遇到了 PHP 错误

Severity: Notice
Message: Array to string conversion
Filename: database/DB_driver.php
Line Number: 1524

下面是我的模型、视图和控制器。

查看

  <h2 class="page-header">
          <i class="fa fa-legal"></i> &nbsp <font color="orange"> Loads To Bid For </font> 
      </h2>
    </div><!-- /.col -->
  </div>

 <?php

                foreach ($h->result() as $row)  
   {
   ?>         

  <div class="row invoice-info">
   <div class="col-sm-1 invoice-col">
    </div>
    <div class="col-sm-3 invoice-col">
    <img src="<?php echo base_url()?>/res/images/goods/1.png">              
    </div>
    <div class="col-sm-4 invoice-col">
    <address>
    Description: <?php echo $row->description;?><br>
    Location Address: <?php echo $row->l_area;?><br>
    Destination Address: <?php echo $row->d_area;?><br>
    Date: <?php echo $row->dom;?><br>
    Time: <?php echo $row->tom;?>
    </address>
    </div>
    <div class="col-sm-2 invoice-col">
    <address>
    </address>
    </div><!-- /.col -->
    <div class="col-sm-2 invoice-col">

        <?php echo form_open('truckeraccount_ctrl/bid'); ?>
        <input type="hidden" class="form-control" name="truckerid" value="<?php 
        $truckerid = $this->session->userdata('truckerid');
        echo $truckerid; ?>" required>
        <input type="text" class="form-control" name="bid_amount[$row->luggage_id]" placeholder="Bid">
        <button type="submit" class="btn bg-orange btn-flat margin">Place Bid</button>
      </div>
  </div>

控制器

 public function bid(){


                        $this->load->model('Truckeraccount_model');
                      //  $luggage_id = $this->uri->segment(3);
                        $this->Truckeraccount_model->bid();
                        redirect('truckeraccount_ctrl');

   } 

型号

function bid(){  

                        $data = array(

                        'luggage_id' => $this->input->post('luggage_id'),
                        'bid_amount' => $this->input->post('bid_amount'),
                        'truckerid' => $this->input->post('truckerid')
                        );
                        //$this->db->where('luggage_id', $luggage_id);
                        $query=$this->db->update('bids', $data);
                        return $query;  

    }

【问题讨论】:

  • 你的问题是什么?我们不是编码服务。
  • 未能在bids表中输入bid_amount。我想知道哪里出错了
  • 会有错误或类似情况,请编辑您的问题并添加这些详细信息。
  • 已编辑以包含错误。谢谢

标签: php mysql codeigniter


【解决方案1】:

错误出现在表单的 bid_amount[$row->luggage_id] 部分。您不能在字段名称中放置第三个括号,如果写入它将被视为一个数组。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多