Memanggil id yang sama apakah bisa untuk pemanggilan data kedalam modal ?

selamat pagi mau bertanya apa bisa memanggil data menurut id tapi id nya itu ada yang sama, kalo bisa pengkodean nya seperti apa apakah ada kode tambahan? mohon pencerahan nya ane sudah mentok....

index.php


<?php
if(isset($_GET['search'])){
$customer = $_GET['customer'];
$material = $_GET['material'];
$collor = $_GET['collor'];
$size = $_GET['size'];
$model = $_GET['model'];
echo"<b>Search result : ".$customer." ".$material." ".$collor." ".$size." ".$model."<b>";
}

?>
<?php
             while(($count<$rpp) && ($i<$tcount)) {
               mssql_data_seek($result,$i);
               $data = mssql_fetch_array($result);

               ?>

<tr>
<td ><center><?php echo ++$no_urut;?></center> </td>
<td class=" md-trigger" data-modal="modal-3" id="<?php $data['cp_cid']?>"><?php echo $data['cp_cid']; ?></td>
<td class=" md-trigger" data-modal="modal-3" id="<?php $data['cp_cid']?>"><?php echo $data['cp_mate']; ?></td>
<td class=" md-trigger" data-modal="modal-3" id="<?php $data['cp_cid']?>"><?php echo $data['cp_hues']; ?></td>
<td class=" md-trigger" data-modal="modal-3" id="<?php $data['cp_cid']?>"><?php echo $data['cp_width']; ?></td>
<td class=" md-trigger" data-modal="modal-3" id="<?php $data['cp_cid']?>"><?php echo $data['cp_mode']; ?></td>
<td class=" md-trigger" data-modal="modal-3" id="<?php $data['cp_cid']?>"><?php echo $data['cp_name']; ?></td>
<td class=" md-trigger" data-modal="modal-3" id="<?php $data['cp_cid']?>"><?php echo $data['cp_unit']; ?></td>
<td class=" md-trigger" data-modal="modal-3" id="<?php $data['cp_cid']?>"><?php echo $data['cp_cury']; ?></td>
<td class=" md-trigger" data-modal="modal-3" id="<?php $data['cp_cid']?>"><?php echo $data['cp_pack']; ?></td>
<td class=" md-trigger" data-modal="modal-3" id="<?php $data['cp_cid']?>" <?php

$A = $data['cp_price'];
$B = $data['cp_cprice'];
$nilai = (($A/$B)*100);

 if ($nilai<15) {
echo 'style="color: #FF0000;"';
}else{
echo 'style="color: #33FFFF;"';
}
 ?> ><?php echo $data['cp_price']; ?></td>

<td class=" md-trigger" data-modal="modal-3" id="<?php $data['cp_cid']?>"><?php echo $data['cp_cprice']; ?></td>
<td class=" md-trigger" data-modal="modal-3" id="<?php $data['cp_cid']?>"><?php echo $data['cp_weight']; ?></td>
<td class=" md-trigger" data-modal="modal-3" id="<?php $data['cp_cid']?>"><?php echo $data['cp_date']; ?></td>
</tr>

<?php
     $i++;
        $count++;
    }

 ?>

<script type="text/javascript">

   $(document).ready(function(){
        $('.md-trigger').click(function () {
            var id = $(this).attr('id');

            //menggunakan fungsi ajax untuk pengambilan data
            $.ajax({
		url : 'detail.php',
                type : 'post',
                data :  'id='+id,
                success : function(data){
                $('#fetched-data').html(data);//menampilkan data ke dalam modal

                }
            });
         });
    });
  </script>

detail.php

<?php

   include "conection.php";

if(isset($_POST ['id'])){
$id = $_POST['id'];
$sql = ("SELECT cp_cid,cp_mate,cp_hues,cp_width,cp_mode,cp_name,cp_unit,cp_cury,cp_pack,cp_price,cp_date,cp_weight,cp_cprice,cp_uprice,cp_temp FROM [cust_pric] WHERE cp_mate = '$id'");
$result = mssql_query($sql);
?>

      <div class="table-responsive">
       <table  class="table table-hover table-custom" id="basicDataTable">
	<thead>
              <tr>
          	 <th ><center>Id_Customer</center></th>
           	 <th ><center>Material</center></th>
           	 <th ><center>Color</center></th>
          	 <th ><center>Size</center></th>
		 <th ><center>Model</center></th>
          	 <th ><center>Name</center></th>
          	 <th ><center>Unit</center></th>
           	 <th ><center>Cp_cury</center></th>
           	 <th ><center>Packing</center></th>
           	 <th ><center>Price Low</center></th>
           	 <th ><center>Price Higt</center></th>
           	 <th ><center>Weight</center></th>
           	 <th ><center>Date</center></th>
             </tr>
	</thead>
<?php while ($row = mssql_fetch_array ($result)) {?>
<tbody>
<tr>
<td><?php echo $row['cp_cid'];?></td>
<td><?php echo $row['cp_mate'];?></td>
<td><?php echo $row['cp_hues'];?></td>
<td><?php echo $row['cp_width'];?></td>
<td><?php echo $row['cp_mode'];?></td>
<td><?php echo $row['cp_name'];?></td>
<td><?php echo $row['cp_unit'];?></td>
<td><?php echo $row['cp_cury'];?></td>
<td><?php echo $row['cp_pack'];?></td>
<td><?php echo $row['cp_price'];?></td>
<td><?php echo $row['cp_cprice'];?></td>
<td><?php echo $row['cp_weight'];?></td>
<td><?php echo $row['cp_date'];?></td>
</tr>
  <?php }
}
 ?>
</tbody>
            </table>
  </div>

avatar Obbytokun
@Obbytokun

186 Kontribusi 16 Poin

Dipost 5 tahun yang lalu

Tanggapan

kode yang ditampilkan tidak begitu relevan dengan pertanyannya, coba bikin contoh simplenya gan, sebelum masuk ke contoh yang besar. Bikin file html + js sederahana, dan coba bikin beberapa div yang punya id yang sama, dan lihat disana hasilnya bisa atau tidaknya

Belum ada Jawaban. Jadi yang pertama Jawaban

Login untuk ikut Jawaban