Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14348

IF Query

$
0
0
Hello everybody,
I have a problem with an IF.
For this query, the total amount of the article should be checked.
If it is exactly 0, an update will be executed.
But if it is above that, it should be ignored.

Example:
The database says I have 5 batteries.
I sell 5, so an update will be executed.

Here are the code:
Model

PHP Code:
    public function karte_gelagert_sum($slug false) {
        $this->db->select('SUM(tb_karte_anzahl) as count');
        $this->db->where('db_karte.tb_karte_karten_stats'$slug);
        $query $this->db->get('db_karte');
        return $query->row_array();
    }

 
   public function insert_artikel($slug) {
 
       if (isset($_POST['add_insert_artikel'])) {
            if(
$this->input->post('add_karte_anzahl') == 0) {
            
// if(0 == 0) {
                
$this->db->set('tb_ygo_karten_stats_aktiv'0);
                
// $this->db->set('tb_ygo_karten_stats_aktiv', 1);
                
$this->db->where('tb_ygo_karten_stats_id'$slug);
                
$this->db->update('db_ygo_karten_stats');
            }
        }
    } 


view:

Code:
<?php echo form_open('Karte/insert_artikel'); ?>
<input type="text" name="add_karte_anzahl" value="<?php echo $test['count']; ?>"><!-- total quantity -->
<input type="hidden" name="add_karte_menge[<?php echo $edition_views['tb_karte_id']; ?>]" value="5"><!-- sale volume -->
<button name="add_insert_artikel" type="submit" required class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="top" title="<?php echo $this->lang->line('all_button_verkauf'); ?>"><span class="glyphicon glyphicon-shopping-cart" aria-hidden="true"></span></button>
<?php echo form_close(); ?>

I do not understand why this does not update.

Viewing all articles
Browse latest Browse all 14348

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>