当点击编辑图标(铅笔图标)后,我能够从数据库中检索记录,但我正在获取在模型中编写的特定id详细信息。如果我们单击编辑图标,则会打开一个弹出窗口,并显示特定用户id的记录。例如下面的图像,如果我单击用户id 3,则记录将被显示,如果我单击用户id 4,则记录将被显示,用户id 5也是一样的。请在这方面给我帮助。
控制器
public function update_retrive()
{
$id = $this->uri->segment(3);
$this->load->model("model_add_user");
$d=$this->model_add_user->update_retrive($id);
$data['posts'] = $d;
}
Model
public function update_retrive($id)
{
$this->db->where('userId',$id);/* I have to select multiple userid but how?*/
$this->db->from('add_user');
$q = $this->db->get();
return $q->result();
}
查看
<div class="table-responsive">
<table class="table table-bordered" >
<thead>
<tr>
<td><b></b></td>
<td><b></b></td>
<td><b>userId</b></td>
<td><b>firtsname</b></td>
<td><b>lastname</b></td>
<td><b>mobileno</b></td>
<td><b>address</b></td>
<td><b>city</b></td>
<td><b>email</b></td>
</tr>
</thead>
<?php
foreach ($user->result() as $row)
{
?>
<tbody><tr >
<td><a href="<?php echo site_url('Welcome/delete/'.$row->userId)?>"><img src="http://localhost/CRM/img/delete.png" name="delete_image" ></a></td>
<!-- <td><a href="<?php echo site_url('Welcome/update/'.$row->userId)?>"><img src="http://localhost/CRM/img/edit.png" name="edit_image" ></a></td>-->
<td><a id="btnclick" href="<?php echo site_url('Welcome/update_retrive/'.$row->userId)?>"><img src="http://localhost/CRM/img/edit.png" name="edit_image" ></a></td>
<td><?php echo $row->userId;?></td>
<td><?php echo $row->firtsname;?></td>
<td><?php echo $row->lastname;?></td>
<td><?php echo $row->mobileno;?></td>
<td><?php echo $row->address;?></td>
<td><?php echo $row->city;?></td>
<td><?php echo $row->email;?></td>
</tr> </tbody>
<?php }
?>
</table>
<form id="form1">
<div id="popupdiv" style="display: none">
<?php foreach($posts as $post){?>
<input type="text" name="userId" placeholder="USER ID" style="width:200px" value='<?php echo $post->userId;?>'>
<input type="date" name="date" style="width:200px" value='<?php echo $post->date;?>'>
<input type="text" name="firtsname" placeholder="FIRST NAME" style="width:200px" value='<?php echo $post->firtsname;?>'>
<input type="text" name="middlename" placeholder="MIDDLE NAME" style="width:200px" value='<?php echo $post->middlename;?>'>
<input type="text" name="lastname" placeholder="LAST NAME" style="width:200px" value='<?php echo $post->lastname;?>'>
<input type="text" name="mobileno" placeholder="ENTER MOBILE NO." style="width:200px" value='<?php echo $post->mobileno;?>'>
<input type="text" name="landline" placeholder="LANDLINE No." style="width:410px" value='<?php echo $post->landline;?>'>
<textarea name="address" placeholder="ENTER ADDRESS" style="width:410px" ><?php echo $post->address;?></textarea>
<input type="text" name="city" placeholder="CITY" style="width:200px" value='<?php echo $post->city;?>'>
<input type="text" name="locality" placeholder="LOCALITY" style="width:200px" value='<?php echo $post->locality;?>'>
<input type="text" name="email" placeholder="ENTER EMAIL" style="width:410px" value='<?php echo $post->email;?>'></br>
<input type="submit" class="submit" name="UPDATE" value="UPDATE" >
<?php }
?>
</div>
</form>
</div>