Dropdownlistten seçilenlere göre aynı sayfanın altında sonuçları listeletmek istiyorum.
ajaxsubmitbutton kullanıyorum controllerdan dönen data array geliyor. Bunu nasıl listeleyebilirim.
controller dosyası
public function actionSorguajax()
{
$pid = $_POST['Rehber']['personelid'];
$birim = $_POST['Rehber']['birimid'];
if ( ( !empty($pid) ) )
{
$sql='Select p.sicilno as scl, p.email as mail, p.ad as ad, p.soyad as soyad, r.dahilino as no ';
$sql=$sql.' FROM personel p left join rehber r on r.personelid = p.id ';
$sql=$sql.' where p.id =:pid';
$command =Yii::app()->db->createCommand($sql);
$command->bindValue(":pid", $pid, PDO::PARAM_STR);
@$a=$command->queryAll();
for ($i=0; $i <count($a) ; $i++) {
$sicilno=$a[$i]['scl'];
$email=$a[$i]['mail'];
$ad=$a[$i]['ad'];
$soyad=$a[$i]['soyad'];
$dahilino=$a[$i]['no'];
/* $sql2='SELECT "resim64" FROM tb_kimlik_resim WHERE "kimlik_id"=:kimlik_id';
$command =Yii::app()->dbpostgre->createCommand($sql2);
$command->bindValue(":kimlik_id", $kimlik_id, PDO::PARAM_STR);
$resim=$command->queryAll();
$resim=$resim[$i]['resim64'];*/
@$dizi[$i] = array(
'sicilno'=>$sicilno,
'email' => $email,
'ad' => $ad,
'soyad'=>$soyad,
'dahilino'=>$dahilino,
'count'=>$i,
);
}
}else if ( ( !empty($birim) ) ) {
$sql='Select p.sicilno as scl, p.email as mail, p.ad as ad, p.soyad as soyad, r.dahilino as no ';
$sql=$sql.' FROM personel p left join rehber r on r.personelid = p.id ';
$sql=$sql.' LEFT JOIN birimler b on b.id=p.birim where b.id =:bid';
$command =Yii::app()->db->createCommand($sql);
$command->bindValue(":bid", $birim, PDO::PARAM_STR);
@$a=$command->queryAll();
for ($i=0; $i <count($a) ; $i++) {
$sicilno=$a[$i]['scl'];
$email=$a[$i]['mail'];
$ad=$a[$i]['ad'];
$soyad=$a[$i]['soyad'];
$dahilino=$a[$i]['no'];
/* $sql2='SELECT "resim64" FROM tb_kimlik_resim WHERE "kimlik_id"=:kimlik_id';
$command =Yii::app()->dbpostgre->createCommand($sql2);
$command->bindValue(":kimlik_id", $kimlik_id, PDO::PARAM_STR);
$resim=$command->queryAll();
$resim=$resim[$i]['resim64'];*/
@$dizi[$i] = array(
'sicilno'=>$sicilno,
'email' => $email,
'ad' => $ad,
'soyad'=>$soyad,
'dahilino'=>$dahilino,
'count'=>$i,
);
}
}else{
@$dizi = array(
'sicilno'=>"",
'email' => "",
'ad' => "",
'soyad'=>"",
'dahilino'=>"",
'count'=>"1",
);
}
echo CJSON::Encode( $dizi );
// $this->render('sorgusonucu',array('dizi'=>@$dizi));
}
view dosyası
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'rehber-form',
'enableAjaxValidation'=>false,
));
?>
<div class="row">
<?php echo $form->labelEx($model,'Dahilisi Aranacak Personel'); ?>
<?php echo $form->dropDownList($model,'personelid', CHtml::listData(Personel::model()->findAllbySql
('SELECT id,CONCAT(ad, " ", soyad) as ad FROM personel '), 'id', 'ad'),array('prompt'=>''));?>
<?php echo $form->error($model,'personelid'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'Dahilisi Aranacak Birim'); ?>
<?php echo $form->dropDownList($model,'birimid', CHtml::listData(Birimler::model()->findAll(array()), 'id', 'birim_adi'),array('prompt'=>''));?>
<?php echo $form->error($model,'birimid'); ?>
<?php echo CHtml::ajaxSubmitButton('Kişileri Getir', array('Rehber/sorguajax'),
array(
'dataType' => 'json',
'success' => 'js:function(data){
$("#Rehber_Ad").html("<b>ADI: </b>"+data.ad);
$("#Nizamiye_Soyad").val(data.sicilno);
$("#sad").val(data.dahilino);
}'
)
);
?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
<table>
<tr>
<td class='border-bottom:1px solid;'>
<tr>
<th width='105px' ><div class="row" size="6"> <?php echo "<div style ='font:15px/21px Arial,tahoma,sans-serif;color:#759053'> Sicil</div>"; ?> </div> <hr></th>
<th width='105px' ><div class="row"> <?php echo "<div style ='font:15px/21px Arial,tahoma,sans-serif;color:#759053'> E-mail</div>" ; ?> </div> <hr></th>
<th width='125px' ><div class="row"> <?php echo "<div style ='font:15px/21px Arial,tahoma,sans-serif;color:#759053'> Ad</div>"; ?> </div> <hr></th>
<th width='125px' ><div class="row"> <?php echo "<div style ='font:15px/21px Arial,tahoma,sans-serif;color:#759053'> Soyad</div>"; ?> </div> <hr></th>
<th width='60px' ><div class="row"> <?php echo "<div style ='font:15px/21px Arial,tahoma,sans-serif;color:#759053'> Dahili</div>"; ?> </div> <hr></th>
</tr>
<?php
//echo '<pre>';print_r(count($dizi[$i]['dahilino']));exit;
for ($i=0; $i <count(5) ; $i++) { ?>
<tr>
<!-- <td height='100px'><div id="YbsUyebilgileri_Kartkodu"><?php // echo strtoupper($aa[$i]['KARTKODU']) ;?></div><br> </td> -->
<th id="Rehber_Sicil"></th><br>
<th id="Rehber_Email"></th><br>
<th id="Rehber_Ad"></th>
<th id="Rehber_Soyad"></th>
<th id="Rehber_Dahili"></th>
<?php /* $resim=$dizi[$i]['kimlikid']; ?>
<td ><div class="photo">
<?php echo '<img src="data:image/jpeg;base64,' .($resim) . '" width="70" />'; ?>
</div></td>
<?php
*/
//}
?>
</tr>
<?php }?>
</td>
</tr>
</table>