发布的变量返回null但不是

时间:2014-04-09 07:13:28

标签: php jquery mysql

我发布一些变量和变量" omzet" en" kosten"我得到返回NULL其他变量返回他们应该。但是当我把sql放在phpmyadmin中时,我得到了正确的变量。

rapportage_model.php:

function rapport_detail_opbrengsten($idKlant){
        $this->db->select('idProject');
                    if ($idKlant > 0){
        $this->db->where('idKlant', $idKlant);}
        $this->db->from('Project');
        $query = $this->db->get();
            foreach($query->result() as $row){
                $project = $row->idProject;
            }
        $this->db->select_sum('Prijs');
                    if ($idKlant > 0){
        $this->db->where('idProject', $project);}
        $this->db->from('Opbrengsten');
        $query = $this->db->get();

        if($query->num_rows()>0){
            return $query->result();
        }
        else{
            return false;
        }
    }

rapportage.php(控制器):

function rapport_detail(){
    $this->load->model('rapportage_model');
    $idKlant = $this->input->get('idKlant');
    $data['opbrengstenproject']= $this->rapportage_model->rapport_detail_opbrengsten($idKlant);
foreach($data['opbrengstenproject'] as $row){
    $compact['omzetproject'] = $row->Prijs;
    }

rapportage.js(ajax post):

$.ajax({
    type: "POST",
    url: "rapportage/rapport_detail?idKlant=" + klant,
    dataType: 'json',
    error: function () {
        alert("Onvoldoende gegevens beschikbaar om rapportage to genereren.");
    },
    success: function (data) { // Plaats data op de juiste plek in de tabel 
        var titel = data.titel.slice(','),
            projecttype = data.projecttype.slice(','),
            projectleider = data.projectleider.slice(','),
            projecttype = data.projecttype.slice(','),
            statusproject = data.statusproject.slice(','),
            startproject = data.startproject.slice(','),
            deadlineproject = data.deadlineproject.slice(','),
            omzetproject = data.omzetproject,
            kostenproject = data.kostenproject,
            margeproject = data.margeproject.slice(','),
            totaalurenproject = data.totaalurenproject,
            totaalminutenproject = data.totaalminutenproject,
            urenkostenproject = data.urenkostenproject;
        console.log(data.omzetproject);
        var str = '';
        for (var i = 0, len = titel.length; i < len; i++) {
            str += "<tr>" + "<td>" + titel[i] + "</td>";
            str += "<td>" + projectleider[i] + "</td>";
            str += "<td>" + projecttype[i] + "</td>";
            str += "<td>" + statusproject[i] + "</td>";
            str += "<td>" + startproject[i] + "</td>";
            str += "<td>" + deadlineproject[i] + "</td>";
            str += "<td>" + omzetproject + "</td>";
            str += "<td>" + kostenproject + "</td>";
            str += "<td>" + margeproject[i] + "</td>";
            str += "<td>" + totaalurenproject + ":" + totaalminutenproject + "</td>";
            str += "<td>" + urenkostenproject + "</td>" + "</tr>";
        }
        alert(JSON.stringify(data));
        $("#details tbody").append(str);
    }
});

rapportage_view:

<div id="resultaat-uitgebreid"><div details>
            <table id="details" border="1">
                <thead>
                    <th>Project:</th>
                    <th>Leider:</th>
                    <th>Type:</th>
                    <th>Status:</th>
                    <th>Startdatum:</th>
                    <th>Deadline:</th>
                    <th>Omzet:</th>
                    <th>Kosten:</th>
                    <th>Marge:</th>
                    <th>Totale Uren:</th>
                    <th>Totale kosten in uren:</th>
                </thead>
                <tbody></tbody>
            </table>

        <td class="rapport-lang-periode"></td>
        </div>                  
    </div> 

0 个答案:

没有答案