I have 5 types of users, and some of them have access to more functions than others.
In my database I have a table for user_type
and a table for users
. In the user
table I have a column rion
for which only one of the user types has values. I need to get only existing values without empty or null or 0 valued data with PHP to use in a select component.
The query I am currently using is:
SELECT COUNT(*) AS `Rows`, `rion` FROM `rdb_users` GROUP BY `rion` ORDER BY `rion`
and my PHP code is like this:
<div class="col-sm-4 col-lg-5 controls">
<?php $CI=g et_instance(); $CI->load->model('show/show_model'); $agents = $CI->show_model->get_users_by_range('all','','rion');?>
<select name="created_by" class="form-control input-sm">
<?php $v=( set_value( 'created_by')!='' ) ? set_value( 'created_by') : $CI->session->userdata('user_id'); ?>
<?php foreach ($agents->result() as $agent) { $sel = ($agent->id== $v)?'selected="selected"':'';?>
<option value="<?php echo $agent->rion; ?>" <?php echo $sel;?>>
<?php echo $agent->rion;?>
</option>
<?php } ?>
</select>
</div>
But this code gives all the data from the column, including no-valued, null or empty fields and shows those in the selection menu. How can I edit this code to hide or remove empty values from other user types? I need just data from "agent" type users.