Guest User

Untitled

a guest
Mar 17th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. <?php
  2.  
  3. $connection= mysqli_connect("localhost","root","","invoices");
  4.  
  5. $invID = $_POST['ID'];
  6.  
  7. $query= "SELECT a.in_no, a.client, a.add, a.Date, a.subTotal a.gTotal, b.id, b.item, b.strength, b.quantity, b.price from invoice a, invoiceItems b where a.in_no = b.in_id AND in_no = '$invID' ";
  8.  
  9. $runQuery = $connection->query($query);
  10.  
  11. if($runQuery->num_rows > 0) {
  12. $result = $runQuery->fetch_array();
  13. } // if num_rows
  14.  
  15. $connection->close();
  16. echo json_encode($result);
  17. ?>
  18.  
  19. function Invoice (ID = null) {
  20.  
  21. if(ID) {
  22. $.ajax({
  23. url: 'fetch.php',
  24. type: 'post',
  25. data: {ID: ID},
  26. dataType: 'json',
  27. success:function(response) {
  28.  
  29. // invoice id
  30. $(".footerClass").append('<input type="hidden" name="Id"
  31. id="invoiceiD" value="'+response.in_no+'" />');
  32.  
  33. // invoice no
  34. $("#No").val(response.in_no);
  35. // Name
  36. $("#Name").val(response.client);
  37. // pat.Address
  38. $("#Add").val(response.add);
  39. // invoice date
  40. $("#Date").val(response.Date);
  41.  
  42. //this data should be in loop
  43. $('#item_').val(response.item);
  44. $('#quantity').val(response.quantity);
  45. $('#price').val(response.price);
  46. $('#total').val(response.quantity*response.price);
  47. calculateTotal();
  48. }
  49. });
  50. }else {
  51. alert('error loading data');
  52. }
  53. }
Add Comment
Please, Sign In to add comment