无法从控制器显示到codeigniter

时间:2016-04-03 07:42:56

标签: codeigniter codeigniter-3

您好我正在尝试显示控制器的结果,以便在Codeigniter中查看。我从模型到控制器获取结果,然后显示详细信息以映射和内部div。

我正在使用biostall在地图上显示。它工作正常。我也希望显示内部div也无效。这是我的代码..

我的模型代码..

function getRegaddress($citycheck,$lat,$lng,$itemid,$hotelid) {
     $return =array();
    // Here goes Query....

    //$query = mysql_query($results);

    if ($query->num_rows() >0) {

        foreach ($query->result() as $row) {
            array_push($return, $row);
        }
            // return $query->result();

        }

        return $return;
    }
}

这里是控制器代码

$data = $this->maps_model->getRegaddress($citycheck,$lat,$lng,$itemid,$hotelid);

$data['hotelname'] = $hotelname;

$config['center'] =  $lat.",".$lng;

$this->load->library('googlemaps');

$this->googlemaps->initialize($config);

foreach ($data as $coordinate) {

    //  $data = array();

    //  $data['values']=$coordinate->hotelname;

    $marker = array();
    $marker['title'] = $coordinate->hotelname;
    $marker['position'] = $coordinate->lat.','.$coordinate->lng;

    $this->googlemaps->add_marker($marker);
}

$data = array();

$data['map'] = $this->googlemaps->create_map();
$this->load->view('templates/_header');
$this->load->view('content/temp-view', $data);
$this->load->view('templates/footer');  

查看代码

<?php echo $map['js']; ?>

<div class="col-lg-8">
<div class="media"><a href="menu/"> </a>                        
<h3 class="media-heading text-danger-theme"><?php echo $hotelname; ?></h3>
<?php echo $map['html']; ?>
</div>
</div>
</div>
</div>
</div>  

在结果中......地图标记显示数据库中的详细信息。但是当我在div上显示delalername时,它显示的错误如...

Severity: Notice
Message: Trying to get property of non-object
Filename: controllers/mapcontrol.php
Line Number: 84
A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: controllers/mapcontrol.php
Line Number: 84

为什么我收到此错误?任何人都知道请帮忙......

这是输出结构

array(3) { [0]=> object(stdClass)#23 (15) { ["hotelid"]=> string(1) "2" ["hoteltype"]=> string(1) "3" ["hotelname"]=> string(18) "Sreekrishna food" ["dealerloc"]=> string(27) "Bengaluru, Karnataka, India" ["lat"]=> string(18) "12.971598700000000" ["lng"]=> string(18) "77.594562699999980" ["dealercity"]=> string(9) "Bengaluru" ["dealeraddress"]=> string(27) "Bengaluru, Karnataka, India" ["type"]=> string(2) "ar" ["stype"]=> string(3) "ggs" ["email"]=> string(15) "local@gmail.com" ["mobile"]=> string(10) "9947485214" ["phone"]=> string(10) "9947485214" ["website"]=> string(0) "" ["distance"]=> string(22) "0.00005899369716644287" } [1]=> object(stdClass)#24 (15) { ["hotelid"]=> string(1) "3" ["hoteltype"]=> string(1) "3" ["hotelname"]=> string(15) "Aey food" ["dealerloc"]=> string(42) "Shivaji Nagar, Bengaluru, Karnataka, India" ["lat"]=> string(18) "12.985650300000000" ["lng"]=> string(18) "77.605692699999960" ["dealercity"]=> string(13) "Shivaji Nagar" ["dealeraddress"]=> string(42) "Shivaji Nagar, Bengaluru, Karnataka, India" ["type"]=> string(2) "ar" ["stype"]=> string(3) "ggs" ["email"]=> string(9) "std@ff.il" ["mobile"]=> string(10) "9947485214" ["phone"]=> string(10) "9947485214" ["website"]=> string(0) "" ["distance"]=> string(18) "1.2265085392649464" } [2]=> object(stdClass)#25 (15) { ["hotelid"]=> string(1) "1" ["hoteltype"]=> string(1) "3" ["hotelname"]=> string(17) "Super - foods" ["dealerloc"]=> string(47) "FM Cariappa Colony, Bengaluru, Karnataka, India" ["lat"]=> string(18) "12.977923000000000" ["lng"]=> string(18) "77.612083499999930" ["dealercity"]=> string(18) "FM Cariappa Colony" ["dealeraddress"]=> string(47) "FM Cariappa Colony, Bengaluru, Karnataka, India" ["type"]=> string(2) "ar" ["stype"]=> string(3) "ggs" ["email"]=> string(11) "ddd@gfgf.in" ["mobile"]=> string(10) "9947485214" ["phone"]=> string(10) "9947485214" ["website"]=> string(12) "www.music.in" ["distance"]=> string(18) "1.2580702750661623" } } 

0 个答案:

没有答案