0
我正在忙着創建一個網頁,將圖紙發送到客戶端並創建發送給客戶端的收據。我遇到麻煩的部分是選擇要添加到收據中的圖紙並更改修訂。將兩個輸入轉換爲一個數組,輸入db codeigniter
圖紙信息分爲兩個表格。第一個包含圖紙編號,標題,等等,第二個只包含修訂歷史。這些表格由圖紙ID鏈接。
要發出圖紙,用戶必須勾選複選框並更改要發佈的圖紙的修訂版。
我想輸入到數據庫中,但我不知道如何創建數組。目前我的控制器需要獲取所有的下拉輸入,並只有勾選的複選框。我只想要與所選複選框關聯的下拉輸入由數據庫更新。
這是我的看法。
<h1>Issue drawing</h1>
<br>
<div id="body">
<div class="row">
<div class="form-group-sm"><lable class="col-sm-2 control-label">Project number:</lable>
<?php
$js = 'onchange="this.form.submit()" class="form-control" id="focusInput"';
echo form_open('dwg_issue/issue_dwg');
echo "<div class=\"col-xs-2\">" . form_dropdown('project_no',$proj_num, $this->input->post('project_no'), $js)."</div>";
echo form_error('project_no', '<div class="col-xs-4"><div class="alert alert-danger fade in"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>','</div></div>');
?>
</div>
</div>
<?php
echo "<noscript>".form_submit('submit','Submit')."</noscript>";
echo form_close();
?>
<form action="<?php echo base_url() . 'index.php/dwg_issue/issue'; ?>" method="post" accept-charset="utf-8" id="issue">
<table title="Client information" class="table table-hover">
<caption><b>List of drawings</b></caption>
<thead>
<tr><th>Project number</th><th>Drawing number</th><th>Client drawing number</th>
<th>Title</th><th>Drawn by</th><th>Revision</th><th>Drawn Date</th><th>Select</th>
</thead>
<tbody>
<?php
// var_dump($client_info);
if(!empty($result))
{
foreach($result as $row)
{
echo "<tr>";
echo "<td>" . $row->project_no . "</td>";
echo "<td>" . $row->sws_dwg_no . "</td>";
echo "<td>" . $row->client_dwg_no . "</td>";
echo "<td>" . $row->dwg_title . "</td>";
echo "<td>" . $row->dwg_by . "</td>";
$rev = array('0' => $row->dwg_rev);
$rev_change = array(
'B' => 'B',
'C' => 'C',
'D' => 'D',
'E' => 'E'
);
$dropdown = array_merge($rev,$rev_change);
echo "<td>" . form_dropdown('dwg_rev['.$row->dwg_id.']',$dropdown) . "</td>";
echo "<td>" . date('Y/m/d', strtotime($row->dwg_date)) . "</td>";
echo "<td>" . form_checkbox('select['.$row->dwg_id.']',$row->dwg_id) . "</td>";
echo "</tr>";
}
}
?>
</tbody>
</table>
<div class="row">
<div class="col-xs-12 col-md-10">Please select client distribution here with other options</div>
<?php
echo "<div class=\"col-xs-6 col-md-2\"><button class=\"btn btn-md btn-primary btn-block\" type=\"submit\" form=\"issue\">Issue drawings</button></div>";
?>
</div>
<br>
<?php
echo form_close();
?>
</div>
我控制器
public function issue_dwg()
{
$data['proj_num'] = $this->model_proj->proj_num_all();
if ($this->input->post('project_no') != '0')
{
$data['result'] = $this->model_issue->list_dwg($this->input->post('project_no'));
}
$data['main_content'] = 'issue_view';
$this->load->view('includes/template.php', $data);
}
//This function takes the selected drawings and create and issue slip
public function issue()
{
$rows = array();
$num_results = count($this->input->post('select'));
for($i = 0; $i < $num_results; $i++)
{
$rows[$i]['select'] = $_POST['select'][$i];
$rows[$i]['dwg_rev'] = $_POST['dwg_rev'][$i];
}
}
的issue_dwg()函數獲得填充與圖號的下拉並填充用分貝的結果圖。
issue()函數需要處理髮布的信息並將其轉換爲數組以傳遞給數據庫。
(我想添加視圖頁面的圖像,但我沒有足夠的信譽做)
感謝您的幫助。有效。現在我需要處理表單驗證......如果修改沒有在選定的圖形上更改,那麼它需要返回並出錯。 –