[eluser]aqifilyaskhan[/eluser]
I am joining two tables, and i want to show data when id of both is equal.
And when id is not equal so show nothing, but it is showing everything
Please Please Please Please Help me.
Thanks in advance.
This is my Controller
<?php
/**
*
*/
class profile extends CI_Controller
{
function __construct()
{
parent::__construct();
}
function index()
{
$this->load->model("profile_model");
$data['profile_records']=$this->profile_model->getAllRecords();
}
}
?>
This is my Model
<?php
/**
*
*/
class profile_model extends CI_Model
{
function __construct()
{
parent::__construct();
}
function getAllRecords()
{
$this->db->select('*');
$this->db->from('ads AS A');// I use aliasing make things joins easier
$this->db->join('membership AS C', 'C.id = A.ad_id', 'INNER');
$this->db->where('A.ad_id = C.ad_fk');
$q = $this->db->get("ads");
if($q->num_rows() > 0)
{
return $q->result();
}
return array();
}
}
?>
This is my views
<?php
foreach ($profile_records as $profile_rows)
{
?>
<span>
echo "<span class='title2'>". $profile_rows->ad_timestamp ."</span>"."<br/>";?>
<?php echo "<span class='title2'>". $profile_rows->ad_title ."</span>"."<br/>";?>
<?php echo "<span class='title'>". $profile_rows->ad_description ."</span>"."<br/>";?>
<?php echo "<span class='title2'>". $profile_rows->cat_type ."</span>"."<br/>";?>
<?php echo "<span class='title2'>". $profile_rows->ad_name ."</span>"."<br/>";?>
<?php echo "<span class='description'>". $profile_rows->ad_phone ."</span>"."<br/>";?>
<?php echo "<span class='name'>". $profile_rows->ad_address ."</span>"."<br/>";?>
<?php echo "<span class='phone'>". $profile_rows->ad_flag."</span>"."<br/>";?>
<?php //echo "<span class='website'>". $row->address ."</span>"."<br/>";?>
</span>
<hr width="600px" />
<?php }?>
How to show null data when data does not exist in database using codeigniter