I have a table in the database (use_shopBlock), which blocks a button in the view, but when I give a <?php var_dump($shopBlock);?>
the result is NULL
.
My view:
<?php
$shopBlock = $this->main_model->configBlock('use_shopBlock');
if($shopBlock == 9){
echo '
<button type="button" id="open-shop" class="btn btn-primary"><i class="fa fa-shopping-cart" aria-hidden="true"></i>Abrir Minha Loja</button>
';
}
?>
My model:
public function configBlock($column = false) {
$this->db->limit(1);
if ($column) {
$this->db->select($column);
}
$query = $this->db->get('users');
$query = $query->result();
if ($query) {
if ($column) {
return $query[0]->$column;
} else {
return $query[0];
}
} else {
return false;
}
}
I will attach how my table was made in MYSQL
Whentheusersignsup,headdsthevalue8intheshopBlocktable,andintheadministrator,whenchangedto"Store Released", changes to 9.
This value 9 should release the button in the view.
Code that changes value in admin:
<div class="form-group">
<label>Ativar loja</label><br>
<select class="form-control" name="shopBlock">
<option <?=(($e && $item->use_shopBlock == '9') ? 'selected' : '')?> value="9">Loja Liberada</option>
<option <?=(($e && $item->use_shopBlock == '8') ? 'selected' : '')?> value="8">Loja Bloqueada</option>
</select>
</div