Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $connection= mysqli_connect("localhost","root","","invoices");
- $invID = $_POST['ID'];
- $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' ";
- $runQuery = $connection->query($query);
- if($runQuery->num_rows > 0) {
- $result = $runQuery->fetch_array();
- } // if num_rows
- $connection->close();
- echo json_encode($result);
- ?>
- function Invoice (ID = null) {
- if(ID) {
- $.ajax({
- url: 'fetch.php',
- type: 'post',
- data: {ID: ID},
- dataType: 'json',
- success:function(response) {
- // invoice id
- $(".footerClass").append('<input type="hidden" name="Id"
- id="invoiceiD" value="'+response.in_no+'" />');
- // invoice no
- $("#No").val(response.in_no);
- // Name
- $("#Name").val(response.client);
- // pat.Address
- $("#Add").val(response.add);
- // invoice date
- $("#Date").val(response.Date);
- //this data should be in loop
- $('#item_').val(response.item);
- $('#quantity').val(response.quantity);
- $('#price').val(response.price);
- $('#total').val(response.quantity*response.price);
- calculateTotal();
- }
- });
- }else {
- alert('error loading data');
- }
- }
Add Comment
Please, Sign In to add comment