gpt4 book ai didi

php - 带有链接的 codeigniter View 中的回显计数行数

转载 作者:行者123 更新时间:2023-11-30 21:22:11 24 4
gpt4 key购买 nike

我想计算行数并在我的 View 中显示链接..当用户点击数字时,链接将转到特定的 url..

这是我的模型:

 function getrequirementsdate($date1,$date2)
{

$this->db->select('*');
$this->db->from('requirements');
$this->db->join('role','role.role_id=requirements.role_id');
$this->db->where('created_date >=', $date1);
$this->db->where('created_date <=', $date2);
$query = $this->db->get();
//echo $this->db->last_query();
$rowcount = $query->num_rows();
//echo $rowcount;
return $query->result();
}

另一个模型:

function getrequirements()
{
$this->db->select('*');
$this->db->from('requirements');
$this->db->join('role','role.role_id=requirements.role_id');
$query = $this->db->get();
// echo $this->db->last_query();
return $query->result();
}

这是我的 Controller :

public function view_requirements_bydate($date1="",$date2="")
{
$data["msg"]="";
$data = array(
'total_item' => $this->ReportModel->getrequirementsdate($date1,$date2)
);
if($date1=='' && $date2=='' )
{
$data['view_requirements'] = $this->ReportModel->getrequirements();
}
else
{
$data['view_requirements'] = $this->ReportModel->getrequirementsdate($date1,$date2);
}
$this->load->view('Reports/view_requirements_bydate',$data);
}

查看:(在这里显示计数)..

<body>
<h4>No of Requirements:</h4>
</body>

这是我的表格代码:

<div class="box-body">
<table id="" class="table table-bordered table-hover">
<thead>
<tr>
<th>Role Name</th>
<th>Vacancies</th>
<th>Experience</th>
<th>Job Description</th>
<th>Hiring Contact Number</th>
<th>Hiring Contact Name</th>
<th>Date</th>

</tr>
</thead>

<?php
foreach ($view_requirements as $idata)
{
?>


<tbody>

<tr id="domain<?php echo $idata->req_id;?>">
<td><?php echo $idata->role_name;?></td>
<td><?php echo $idata->vacancies;?></td>

<td><?php echo $idata->experience;?></td>
<td><?php echo $idata->jd;?></td>
<td><?php echo $idata->hiring_contact_number;?></td>
<td><?php echo $idata->hiring_contact_name;?></td>
<td><?php echo $idata->created_date;?></td>



</tr>



<?php
}
?>


</tbody>

</table>

谁能帮我怎么做谢谢..

最佳答案

模型 1

function getrequirementsdate($date1,$date2)
{

$this->db->select('*');
$this->db->from('requirements');
$this->db->join('role','role.role_id=requirements.role_id');
$this->db->where('created_date >=', $date1);
$this->db->where('created_date <=', $date2);
$query = $this->db->get();
return $query->result_array();
}

模型 2

function getrequirements()
{
$this->db->select('*');
$this->db->from('requirements');
$this->db->join('role','role.role_id=requirements.role_id');
$query = $this->db->get();
return $query->result_array();
}

Controller

function view_requirements_bydate($date1="",$date2="")
{
$data["msg"]="";

if($date1 =='' && $date2 =='' )
{
$data['view_requirements'] = $this->ReportModel->getrequirements();
}
else
{
$result_array = $this->ReportModel->getrequirementsdate($date1,$date2);

$data['total_item'] = count($result_array);
$data['view_requirements'] = $this->ReportModel->getrequirementsdate($date1,$date2);

}
$this->load->view('Reports/view_requirements_bydate',$data);
}

查看

<body>
<h4>echo $total_item;</h4> // or print_r($total_item)
</body>

关于php - 带有链接的 codeigniter View 中的回显计数行数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42359326/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com