freddy0512

dasdasdasdas

Apr 4th, 2015
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. if(!empty($_POST['type'])){
  2. $type = $_POST['type'];
  3. $name = $_POST['name_startsWith'];
  4.  
  5. $query = "SELECT `id_barang`, `nama_barang`, `jumlah_all` FROM `tabel_barang` where UPPER($type) LIKE '".strtoupper($name)."%'";
  6. $result = $this->db->query($query)->result_array();
  7. $data = array();
  8. foreach ($result as $row) {
  9.  
  10. if ($row['jumlah_all']=='')
  11. {
  12.  
  13. echo "<script>
  14. alert ('data kosong');
  15. </script>"
  16. }
  17. else
  18. {
  19. $name = $row['id_barang'].'|'.$row['nama_barang'].'|'.$row['jumlah_all'];
  20. array_push($data, $name);
  21. }
  22.  
  23. }
  24. echo json_encode($data);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment