Welcome Guest, Not a member yet? Register   Sign In
needed help for grinding query
#1

Hello everybody,
I have a script query that adds more columns to me.
Now I want to let the sum of the $briefmarke_preis find out the actual ID.
So if in the selection in the view the numbers enter 0.05 + 0.10 + 1.00.
In the database tb_briefmarke_sum you should find the actual ID (in this case ID23).
But unfortunately he does not find the right ID.

Can you help me there



view
Code:
    <tbody>
        <tr id="addr0">
            <td>
                <select required class="form-control btn-xs" name="add_meng[]">
                    <option value="">-</option>
                    <option value="1" selected>1</option>
                    <option value="2">2</option>
                    <option value="3">3</option>
                    <option value="4">4</option>
                </select>
            </td>
            <td>
                <select required class="form-control btn-xs" name="add_briefmarke[]">
<?php
    $SQL = "SELECT
                *
            FROM
                db_porto
            LEFT JOIN
                db_land
                    ON
                        db_land.tb_land_id = db_porto.tb_porto_land
            LEFT JOIN
                db_briefmarke
                    ON
                        db_briefmarke.tb_briefmarke_id = db_porto.tb_porto_briefmarke
            LEFT JOIN
                db_versand_typ
                    ON
                        db_versand_typ.tb_versand_typ_id = db_briefmarke.tb_briefmarke_versand_typ
            WHERE
                db_land.tb_land_id = ".$rechnung['tb_kunde_land']."
                    AND
                        db_briefmarke.tb_briefmarke_aktiv = 1
            ORDER BY
                db_briefmarke.tb_briefmarke_sum";
    $query = $this->db->query($SQL);
    foreach ($query->result() as $briefmarke) {
?>
                    <option value="<?php echo $briefmarke->tb_briefmarke_preis."#".$briefmarke->tb_briefmarke_id; ?>" <?php if($rechnung['tb_rechnung_briefmarke'] == $briefmarke->tb_briefmarke_id){echo "selected";} ?>><?php echo number_format($briefmarke->tb_briefmarke_sum,2,",","."); ?>&nbsp;<?php echo $this->lang->line('all_eur'); ?>&nbsp;-&nbsp;<?php echo $briefmarke->tb_versand_typ_name; ?></option>
<?php
    }
?>
                </select>
            </td>
            <td><a id='delete_row'><?php echo $this->lang->line('all_new_del'); ?></a></td>
        </tr>
        <tr id='addr1'></tr>
<script type="text/javascript">
    $(document).ready(function(){
     var i=1;
    $("#add_row").click(function(){
     $('#addr'+i).html("<td><select required class='form-control btn-xs' name='add_meng["+i+"]'><option value=''>-</option><option value='1' selected>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option></select></td><td><select required class='form-control btn-xs' name='add_briefmarke["+i+"]'>?><?php $query = $this->db->query($SQL); foreach ($query->result() as $briefmarke) { ?><option value='<?php echo $briefmarke->tb_briefmarke_preis.'#'.$briefmarke->tb_briefmarke_id; ?>' <?php if($rechnung['tb_rechnung_briefmarke'] == $briefmarke->tb_briefmarke_id){echo 'selected';} ?>><?php echo number_format($briefmarke->tb_briefmarke_sum,2,',','.'); ?>&nbsp;<?php echo $this->lang->line('all_eur'); ?>&nbsp;-&nbsp;<?php echo $briefmarke->tb_versand_typ_name; ?></option><?php } ?></select></td><td><a id='delete_row'><?php echo $this->lang->line('all_new_del'); ?></a></td>");

     $('#tab_logic').append('<tr id="addr'+(i+1)+'"></tr>');
     i++;
 });
    $("#delete_row").click(function(){
        if(i>1){
         $("#addr"+(i-1)).html('');
         i--;
         }
     });

});
</script>
    </tbody>

model
PHP Code:
                    $formData = array();
                    
// $edition_stats_id = $karte_id = array();
                    
$id_briefmarke = array();
                    for(
$i 0$i count($this->input->post('add_meng')); $i++) {
                        
$array_briefmarke explode ('#',$this->input->post('add_briefmarke')[$i]);
                        
$briefmarke_preis $array_briefmarke[0];
                        
$briefmarke_id $array_briefmarke[1];
                        
// $this->db->set('tb_briefmarke_menge', 'tb_briefmarke_menge -'.$this->input->post('add_meng')[$i], FALSE);
                        // $this->db->where('tb_briefmarke_id', $briefmarke_id);
                        // $this->db->update('db_briefmarke');

                        
$this->db->where('tb_briefmarke_aktiv'1);
                        
$this->db->like('tb_briefmarke_preis'$briefmarke_preis[$i]);
                        
$result $this->db->get('db_briefmarke');
                        if(
$result->num_rows() < 1) {
                        }
                        else {
                            
$id_briefmarke[] = $result->row()->tb_briefmarke_id;
                        }

                        
$this->db->set('tb_umsatz_briefmarke_id'$id_briefmarke[$i]);
                        
// $this->db->set('tb_umsatz_briefmarke', 'tb_umsatz_briefmarke +'.$briefmarke_preis, FALSE);
                        
$this->db->where('tb_umsatz_id'$umsatz_id);
                        
$this->db->update('db_umsatz');
                        
// echo "<pre>"; print_r($briefmarke_id); die;
                    

Reply




Theme © iAndrew 2016 - Forum software by © MyBB