Welcome Guest, Not a member yet? Register   Sign In
Forward foreach query
#1

Hello everybody,
How can I pass on a query that is on a particular line in FOREACH?
So I want to let the dedication that comes from the
Code:
$this->db->set('tb_artikel_anzahl', $this->input->post('edit_karte_menge')[$artikel_id]);
be entered in the line of
Code:
$this->db->set('tb_rechnung_menge', $this->input->post('edit_artikel_anzahl'));



View:
PHP Code:
<?php echo form_open('Rechnung/update_rechnung'); ?>
            <input type="hidden" name="edit_rechnung_id" value="<?php echo $get_rechnung['tb_rechnung_id']; ?>">
            <div class="modal-body">
                <div class="row">
                    <div class="col-md-1"><h4><label class="label label-success">#</label></h4></div>
                    <div class="col-md-9"><h4><label class="label label-success">Karten Information</label></h4></div>
                    <div class="col-md-1"><h4><label class="label label-success"><?php echo $this->lang->line('all_tag_preis'); ?></label></h4></div>
                    <div class="col-md-1"><h4><label class="label label-success">Aktion</label></h4></div>
                </div>
<?php foreach ($view_rechnung_karte as $warenkorb_karte): ?>
                <div class="row">
                    <input type="text" name="edit_artikel_id[<?php echo $warenkorb_karte['tb_artikel_id']; ?>]" value="<?php echo $warenkorb_karte['tb_artikel_id']; ?>">
                    <div class="col-md-1"><input type="text" class="form-control input-sm" name="edit_karte_menge[<?php echo $warenkorb_karte['tb_artikel_id']; ?>]" value="<?php echo $warenkorb_karte['tb_artikel_anzahl']; ?>"></div>
                </div>
<?php endforeach;
    foreach (
$view_rechnung_produckt as $warenkorb_produckt):
?>
                <div class="row">
                    <input type="text" name="edit_artikel_id[<?php echo $warenkorb_produckt['tb_artikel_id']; ?>]" value="<?php echo $warenkorb_produckt['tb_artikel_id']; ?>">
                    <div class="col-md-1"><input type="text" class="form-control input-sm" name="edit_karte_menge[<?php echo $warenkorb_produckt['tb_artikel_id']; ?>]" value="<?php echo $warenkorb_produckt['tb_artikel_anzahl']; ?>"></div>
                </div>
<?php endforeach; ?>
            </div>
            <div class="modal-footer">
                <button type="submit" class="btn btn-success btn-xs"><?php echo $this->lang->line('all_button_save'); ?></button>
                <button type="button" class="btn btn-danger btn-xs" data-dismiss="modal">Abbrechen</button>
            </div>
<?php echo form_close(); ?>

Model:
PHP Code:
            public function update_rechnung($slug)
                {
                    foreach (
$this->input->post('edit_artikel_id') as $artikel_id)
                        {
                            
// $this->db->set('tb_artikel_preis', floatval(str_replace(',', '.', $this->input->post('add_preis')[$artikel_id])));
                            // $this->db->set('tb_artikel_kunde', $kunde_id);
                            // $this->db->set('tb_artikel_rechnung', $slug);
                            // $this->db->set('tb_artikel_time_rese', date('Y.m.d H:i:s'));
                            // $this->db->set('tb_artikel_status', 2);
                            // $this->db->set('tb_artikel_anzahl', 'tb_artikel_anzahl +'.$this->input->post('edit_karte_menge')[$artikel_id], FALSE);
                            
$this->db->set('tb_artikel_anzahl'$this->input->post('edit_karte_menge')[$artikel_id]);
                            
$this->db->where('tb_artikel_id'$artikel_id);
                            
$this->db->update('db_artikel');
                        }

                    
$this->db->set('tb_rechnung_menge'$this->input->post('edit_artikel_anzahl'));
                    
$this->db->where('tb_rechnung_id'$slug);
                    
$this->db->update('db_rechnung'); 
Reply




Theme © iAndrew 2016 - Forum software by © MyBB