在我的控制器中我用这种方式.我想通过重定向将可变数据传递给控制器的索引函数
$in=1;
redirect(base_url()."home/index/".$in);
Run Code Online (Sandbox Code Playgroud)
我的索引功能是
function index($in)
{
if($in==1)
{
}
}
Run Code Online (Sandbox Code Playgroud)
但我得到一些错误,如未定义的变量.
我怎么解决这个问题?
我在将数据更新到数据库时遇到问题.例如:在我的表中包含特定id的三行.因此,编辑时通过ng-repeat显示内容.
视图
<tr class="odd gradeX" ng-repeat="d in data">
<td> <input type="text" name="tools" class="form-control" ng-model="d.po_tools" placeholder="Tools"> </td>
<td> <input type="text" name="qnty" class="form-control" ng-model="d.po_quantity" placeholder="Quantity"> </td>
</tr>
Run Code Online (Sandbox Code Playgroud)
CI控制器
public function updatePurchaseDetails()
{
$po_id = $this->uri->segment(4);
$data = file_get_contents('php://input');
$this->model->update_purchase_data($data,$data['count']);
}
Run Code Online (Sandbox Code Playgroud)
模型
public function update_purchase_data($data,$count)
{
$count=$count+1;
for($i=0;$i<$count;$i++)
{
$data_array = array(
'po_id' => $id,
'po_tools' => $data['data']['po_tools'] ,
'po_quantity' =>$data['data']['po_quantity']
);
$this->db->update('purchase_order_tool', $data_array);
$this->db->where('po_id',$purchase_id);
}
}
Run Code Online (Sandbox Code Playgroud)
如何在提交时将编辑的数据更新为db.
我想将数据更新为多个ID,我使用所有ID
控制者
public function getIds(){
for($i=0;$i<count($_POST['std_id']);$i++){
echo $_POST['std_id'][$i];
$student_id[]=$_POST['std_id'][$i];
}
Run Code Online (Sandbox Code Playgroud)
我不知道该如何更新?
如何编写模态函数?
在我的视图页面中。我有一个用于输入评论的文本框。在我的 codeigniter 验证中,只允许使用 alpha。
我需要在评论字段中允许空格、逗号、点、连字符.. 如何在我的验证中设置规则
$this->form_validation->set_rules('e_comment', 'Comments', 'required|alpha');
Run Code Online (Sandbox Code Playgroud) 在我的控制器中有一个向一个收件人发送电子邮件的代码,但我想向多个收件人发送邮件。不使用抄送、密送或直接赋值。我想通过前端输入逗号分隔的邮件 ID
如何以逗号分隔的形式获取每个邮件ID?
控制器:
public function shopshare($userid,$shopname,$shop_id)
{
$from_email=$this->input->post('from_email');
$to_email=$this->input->post('to_email');
$subject_url=$this->input->post('url');
$message=$this->input->post('message');
$this->email->from($from_email);
$this->email->to($to_email);
$this->email->subject($url);
$this->email->message($message);
$this->email->send();
redirect(base_url().'shop/shopDetail/'.$shop_id.'/'.$shopname);
}
Run Code Online (Sandbox Code Playgroud)
看法:
<label>
<span>To:</span>
<input id="to_email" type="text" name="to_email[]" placeholder="To Email Address">
</label>
Run Code Online (Sandbox Code Playgroud) 在我的控制器代码中包含附加形式的html代码。当我将参数传递给onclick函数时,我没有在相应函数中获取参数。
控制者
foreach ($cart as $item){
$row_id = $item['rowid'];
// $count++;
$output.='
<tr>
<td>'.$item['name'].'</td>
<td>'.$item['price'].'</td>
<td>'.$item['qty'].'</td>
<td>'.number_format($item['subtotal'],2).'</td>
<td> <a href="" onclick="remove("'.$row_id.'")" class="item-remove"><i class="zmdi zmdi-close"></i></a></td>
</tr>
';
}
Run Code Online (Sandbox Code Playgroud)
脚本
function remove(row_id)
{
alert(row_id);
}
Run Code Online (Sandbox Code Playgroud)
Onclick函数remove(),警报不起作用
我想把限制10放在这里
function getArticles($search_key,$pub_status)
{
$sql="SELECT * FROM (`ms_article`) ";
if($search_key != '')
{
$sql.="WHERE (";
$words = explode(" ",$search_key);
for($i=0;$i<count($words);$i++)
{
$title_con.="`article_title` LIKE '%".$words[$i]."%' OR";
$abstract_con.="`article_abstract` LIKE '%".$words[$i]."%' OR";
$keywords_con.="`article_keywords` LIKE '%".$words[$i]."%' OR";
}
$sql.=$title_con.$abstract_con.substr($keywords_con, 0, -2).") AND (`article_status` = 1 ";
} else{
$sql.="WHERE (`article_status` = 1 ";
}
if($pub_status==0){
$sql.="AND `private_status` <> 1";
}
$sql.=")";
$result=$this->db->query($sql) ;
// echo[$result];
// return $result;
}
Run Code Online (Sandbox Code Playgroud)
但我不知道限制附加在该查询中.我在哪里可以放置这个以及如何在codeigniter中回显查询?
我有两张桌子。我需要从第一张表中选择所有行(仅一个条件hotel_id = 2),并从第二张表中选择所有行(基于条件)。但是我使用的左联接仅从第二张表中获取数据。
询问
SELECT R.name room_name,
R.id room_id,
UD.discount
FROM user_discounts UD
LEFT
JOIN rooms R
ON R.id = UD.room_id
WHERE UD.user_id = 1482
AND UD.hotel_id = 2
Run Code Online (Sandbox Code Playgroud)
我需要显示所有房间,但现在在两个表中显示公共房间。
php ×7
codeigniter ×6
mysql ×3
javascript ×2
angularjs ×1
email ×1
jquery ×1
sql ×1
validation ×1