[英]How to make the records clickable
how to make my records clickable? 如何使我的记录可点击? for example the names of my records..so that when i click them i will be redirected to a new page where i can print that record and its other info.. here's where my table looks like 例如我的记录的名称..所以,当我点击它们时,我将被重定向到一个新的页面,我可以打印该记录和其他信息..这里是我的表看起来像
<div id="vi">
<div id = "search_field">
<?php
$search_field = array('name'=>"search_field",'placeholder'=>"Search booking : Type the name of guest.");
echo form_open('site/view');
echo form_input($search_field);
echo form_submit('search',"Search");
?>
</div>
<?php
$this->table->set_heading("Name","Nationality","Contact Number","Number of Guest","Date of Arrival","Package","Other Request","Delete Record","Edit");
$qry = $this->db->like('name',$search_key)->get('booking');
if ($qry->num_rows > 0) {
foreach ($qry->result() as $row) {
$this->table->add_row($row->name,$row->nationality,$row->contactnum,$row->number_of_guest,$row->date,$row->package,$row->request,anchor('site/delete/'.$row->id, 'Delete'),anchor('site/update/'.$row->id, 'Edit'));
}
}
else{
echo "No records found!";
}
echo $this->table->generate();
Try this one 试试这个吧
<?php
$this->table->add_row("<a href='yourpage.php?name=$name' target='_blank'>$row->name
</a>",$row->nationality,$row->contactnum,$row->number_of_guest,
$row->date,$row->package,$row->request,anchor('site/delete/'.$row->id,
'Delete'),anchor('site/update/'.$row->id, 'Edit'));
?>
If the datas comes form you DB , you'll do something like that : 如果数据来自您的数据库,您将执行以下操作:
<?php
$query = "SELECT ..... FROM....";
$res = mysql_query($query);
// HEADER
$this->table->set_heading("Name","Nationality","Contact Number","Number of Guest","Date of Arrival","Package","Other Request","Delete Record","Edit");
while($res=mysql_fetch_array($res)){
$id = mysql_fetch_array("id");
$name = mysql_fetch_array("name");
$nationnality = mysql_fetch_array("nationnality");
$guests = mysql_fetch_array("guests");
$date = mysql_fetch_array("date");
//...
$this->table->add_row("<a href='secondPage.php?id=$id'>".$name."<a>",$nationnality,$guests,$date);
}
?>
you query get infos in the db, and for each result you create a new line. 您在数据库中查询获取信息,并为每个结果创建一个新行。
then , you need a link with something to identify your line from the others , so each line have a different id . 然后,您需要一个链接来识别其他人的行,因此每行都有不同的ID。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.