Jump to content

if statements


petroz

Recommended Posts

Hey Guys,

 

I am creating an array and I have a need to put a if statement inside it. Is this even possible?

 

Here is where I am at so far, its just not working.


function load_permissions($gid)
    {
    	$data = array();
    	$this->db->select('`groups`.`name` AS `permission_name`, `permissions`.``');
	$query = $this->db->get('`groups`,`permissions`');
	if ($query->num_rows() > 0){
		foreach ($query->result_array() as $row){
	 		$data[] = array(
	 			"name" => $row['permission_name'],
	 			"read" => if($row['level'] >= 1)
	 			 { 
	 			 	img("img/true.gif")
	 			 } else { 
	 			 	img("img/false.gif")
	 			 },

	 		);
	 	}
	 }

	 $query->free_result();
	return $data;

 

Thanks,

Peter

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.