在javascript中附加php echo

时间:2017-10-26 10:26:15

标签: javascript codeigniter jquery-select2

This is image want to make selct2 function... thanks .append($(<?php echo $property_address1;?>))这是我要附加的javascript代码..这是select2函数实际上我想要多个select2 onchange fucntion是必需的...

    public function test($id = null)
    {
        $this->layout->set(
                array(
                    'property_address1' => $this->mdl_quotes->property_address1()
                     )
                 );
        $this->load->model('mdl_quotes');
        $this->layout->buffer('content', 'quotes/test'); 
        $this->layout->render();
    }

我的控制器功能

function property_address1()
{
     $query = $this->db->query('SELECT host,price,city,property_thumbnail, apartments_type, contactnumber, contactperson,photographlinks,emailid, propertyaddress FROM tbl_contacts')->result();
     $output = '<select id="neww" class="property_add_ form-control">';


    foreach ($query as $row) 
    {
        //echo $row->location;
        $output .= "<option value='". $row->propertyaddress ."'";
        $output .= " data-propertyaddress='" . $row->propertyaddress ."'" ;
        $output .= " data-host_name='" . $row->host ."'" ;

        $output .= " data-apartments_type ='" . $row->apartments_type."'" ;

        $output .= " data-city ='" . $row->city."'" ;

        $output .= " data-property_thumbnail='" . $row->property_thumbnail."'" ;

        $output .= " data-price='" . $row->price."'" ;

        $output .= " data-contactperson='" . $row->contactperson ."'" ;
        // $output. = $row->pincode.", ".$row->city.", ".$row->location;
        $output .= " data-photographlinks='" . $row->photographlinks ."'" ;
        $output .= " data-emailid='" . $row->emailid ."'" ;
        $output .= " data-contactnumber='". $row->contactnumber . "'>" ;
        $output .=   $row->host . ' , '.$row->propertyaddress . ' ,'.$row->price. ' ,'.$row->apartments_type. ' , '. $row->contactperson . ' , ' . $row->contactnumber. "</option>";
    }
    $output .= '</select>';
    //var_dump($output);
    return $output;

    }

0 个答案:

没有答案