Welcome Guest, Not a member yet? Register   Sign In
Show null when data does not exist in database
#1

[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/>";?&gt;
&lt;?php echo "<span class='title2'>". $profile_rows->ad_title ."</span>"."<br/>";?&gt;
&lt;?php echo "<span class='title'>". $profile_rows->ad_description ."</span>"."<br/>";?&gt;
&lt;?php echo "<span class='title2'>". $profile_rows->cat_type ."</span>"."<br/>";?&gt;
&lt;?php echo "<span class='title2'>". $profile_rows->ad_name ."</span>"."<br/>";?&gt;
&lt;?php echo "<span class='description'>". $profile_rows->ad_phone ."</span>"."<br/>";?&gt;
&lt;?php echo "<span class='name'>". $profile_rows->ad_address ."</span>"."<br/>";?&gt;
&lt;?php echo "<span class='phone'>". $profile_rows->ad_flag."</span>"."<br/>";?&gt;
&lt;?php //echo "<span class='website'>". $row->address ."</span>"."<br/>";?&gt;
</span>
<hr width="600px" />
&lt;?php }?&gt;





How to show null data when data does not exist in database using codeigniter


Messages In This Thread
Show null when data does not exist in database - by El Forum - 09-13-2014, 10:06 AM
Show null when data does not exist in database - by El Forum - 09-13-2014, 10:27 AM
Show null when data does not exist in database - by El Forum - 09-13-2014, 04:10 PM
Show null when data does not exist in database - by El Forum - 09-13-2014, 06:27 PM
Show null when data does not exist in database - by El Forum - 09-13-2014, 07:57 PM
Show null when data does not exist in database - by El Forum - 09-13-2014, 08:13 PM
Show null when data does not exist in database - by El Forum - 09-14-2014, 03:55 AM
Show null when data does not exist in database - by El Forum - 09-14-2014, 02:01 PM



Theme © iAndrew 2016 - Forum software by © MyBB