Jump to content

Angeleyezz

Members
  • Posts

    104
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Angeleyezz's Achievements

Member

Member (2/5)

0

Reputation

  1. I just figured that out and I think I got it working now, least till a new problem with it arises. here ill show you what I did. its not as clean as yours though lol. i gotta really clean the code on this script up, it seems like there is a lot of redundancy on it. <?php $title = "View Invoice"; include("includes/header.php"); $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } $invoice_number = $_GET['id']; // Select MYSQL Database mysql_select_db("terra_elegante_operations", $con); // ALL QUERIES FOR CREDIT THAT NEEDS TO BE APPLIED // Query the deposit $deposit_query2 = mysql_query("SELECT * FROM invoice_entries, sku_codes WHERE invoice_entries.invoice_number = $invoice_number AND invoice_entries.sku_number = sku_codes.sku AND sku_codes.sku = 01-00") or die(mysql_error()); if ($row = mysql_fetch_array($deposit_query2)) { $deposit = $row['price_each']; } else { $deposit = 0; } // Query the (Senior Citizen Discount - 01-02) $senior_discount_query_2 = mysql_query("SELECT * FROM invoice_entries, sku_codes WHERE invoice_entries.invoice_number = $invoice_number AND invoice_entries.sku_number = sku_codes.sku AND sku_codes.sku = 01-02") or die(mysql_error()); if ($row = mysql_fetch_array($senior_discount_query_2)) { $senior_discount = $row['price_each']; } else { $senior_discount = 0; } // Query the (Promotional Discount - 03-00) $promo_discount_query_2 = mysql_query("SELECT * FROM invoice_entries, sku_codes WHERE invoice_entries.invoice_number = $invoice_number AND invoice_entries.sku_number = sku_codes.sku AND sku_codes.sku = 03-00") or die(mysql_error()); if ($row = mysql_fetch_array($promo_discount_query_2)) { $promo_discount = $row['price_each']; } else { $promo_discount = 0; } // / END ALL QUERIES FOR CREDIT THAT NEEDS TO BE APPLIED // Query invoice number $query_client_invoice = mysql_query("SELECT * from client_invoices where invoice_number = $invoice_number"); // Assign Variables from client_invoices table. $row = mysql_fetch_array($query_client_invoice); $account_number = $row['account_number']; $invoice_date = $row['invoice_date']; $invoice_status = $row['invoice_status']; $due_date = $row['due_date']; // Query Client Information $query_client_information = mysql_query("SELECT * FROM client_information where account_number = $account_number"); // Assign Variables from client_information table. $row = mysql_fetch_array($query_client_information); $name_first = $row['name_first']; $name_last = $row['name_last']; $address = $row['address']; $city = $row['city']; $state = $row['state']; $zipcode = $row['zipcode']; $telephone = $row['telephone']; $telephone_alt = $row['telephone_alt']; $email = $row['email']; ?> <table border="0" cellspacing="0" cellpadding="0" width="100%" bordercolor="#000000"> <tr> <td><font face="verdana" size="2" color="#000000"><b><?php echo "<a class='bubble_nav' href='edit_invoice.php?id=$invoice_number'>EDIT INVOICE</a>"; ?> | <?php echo "<a class='bubble_nav' href='print_invoice.php?id=$invoice_number' target='_blank'>PRINT INVOICE</a>"; ?></b></font></td> </tr> </table> <!-- Invoice Heading - Account #, Invoice #, Name, Address, Telephone #'s --> <br /> <table border="0" cellspacing="0" cellpadding="2" width="100%" bordercolor="#000000"> <tr> <td colspan="4" align="left"><font face="verdana" size="3" color="#000000"><b><u>Invoice Date: <?php echo $invoice_date; ?></u></b></font></td> </tr> <td width="20%"><font face="verdana" size="2" color="#000000">Account Number:</font></td> <td width="40%"><font face="verdana" size="2" color="#000000"><?php echo "<a class=\"bubble_nav\" href='show_client.php?id=$account_number'>$account_number</a\>"; ?></font></td> <td width="20%"><font face="verdana" size="2" color="#000000">Telephone</font></td> <td width="20%"><font face="verdana" size="2" color="#000000"><?php echo $telephone; ?></font></td> </tr> <tr> <td><font face="verdana" size="2" color="#000000">Invoice Number:</font></td> <td><font face="verdana" size="2" color="#000000"><?php echo $invoice_number; ?></font></td> <td><font face="verdana" size="2" color="#000000">Telephone Alt</font></td><td><font face="verdana" size="2" color="#000000"><?php echo $telephone_alt ?></font></td> </tr> <tr> <td colspan="2"><font face="verdana" size="2" color="#000000"><br /><?php echo $name_last; ?> , <?php echo $name_first; ?></font></td> <td align="left" valign="bottom" colspan="2" rowspan="3"><font face="verdana" size="3" color="#000000"><b>Status: <?php echo $invoice_status ?></b><br />Due Date:<?php echo $due_date; ?></font></td> </tr> <tr> <td colspan="2"><font face="verdana" size="2" color="#000000"><?php echo $address ?></font></td> </tr> <tr> <td colspan="2"><font face="verdana" size="2" color="#000000"><?php echo $city; ?>, <?php echo $state; ?> <?php echo $zipcode; ?></font></td> </tr> </table> <!-- / End Invoice Heading --> <!-- Begin Invoice Entries SQL & Table Structure --> <br /><br /><br /> <!-- Out of the while loop / Top of table --> <table bgcolor="#000000" border="0" cellspacing="1" cellpadding="2" width="100%" bordercolor="#000000"> <tr bgcolor="#CCCCCC"> <td align="center" width="5%"><font face="verdana" size="2" color="#000000"><b>QTY</b></font></td> <td align="center" width="10%"><font face="verdana" size="2" color="#000000"><b>SKU</b></font></td> <td align="center" width="30%"><font face="verdana" size="2" color="#000000"><b>DESCRIPTION</b></font></td> <td align="center" width="25%"><font face="verdana" size="2" color="#000000"><b>LOCATION</b></font></td> <td align="center"width="15%"><font face="verdana" size="2" color="#000000"><b>EACH</b></font></td> <td align="center" width="15%"><font face="verdana" size="2" color="#000000"><b>TOTAL</b></font></td> </tr> <?php // Query the deposit $deposit_query = mysql_query("SELECT * FROM invoice_entries, sku_codes WHERE invoice_entries.invoice_number = $invoice_number AND invoice_entries.sku_number = sku_codes.sku AND sku_codes.sku = 01-00") or die(mysql_error()); while($row = mysql_fetch_array($deposit_query)) { $deposit = $row['price_each']; $deposit_location = $row['location']; $deposit_description = $row['sku_description']; $deposit_quantity = $row['quantity']; $deposit_sku = $row['sku']; ?> <tr bgcolor="#c2f48c"> <td align="center"><font face="verdana" size="1" color="#000000"><i><b><?php echo $deposit_quantity; ?></b></i></font></td> <td align="center"><font face="verdana" size="1" color="#000000"><i><b><?php echo $deposit_sku ?></b></i></font></td> <td><font face="verdana" size="1" color="#000000"><i><b><?php echo $deposit_description; ?></b></i></font></td> <td align="center"><font face="verdana" size="1" color="#000000"><i><b><?php echo $deposit_location; ?></b></i></font></td> <td align="right"><font face="verdana" size="1" color="#000000"><i><b>$<?php echo $deposit; ?></b></i></font></td> <td align="right"><font face="verdana" size="1" color="#000000"><i><b>$<?php echo $deposit; ?></b></i></font></td> </tr> <?php } // Query the Senior Discount $senior_discount_query = mysql_query("SELECT * FROM invoice_entries, sku_codes WHERE invoice_entries.invoice_number = $invoice_number AND invoice_entries.sku_number = sku_codes.sku AND sku_codes.sku = 02-00") or die(mysql_error()); while($row = mysql_fetch_array($senior_discount_query)) { $senior_discount = $row['price_each']; $senior_discount_location = $row['location']; $senior_discount_description = $row['sku_description']; $senior_discount_quantity = $row['quantity']; $senior_discount_sku = $row['sku']; ?> <tr bgcolor="#f8ec66"> <td align="center"><font face="verdana" size="1" color="#000000"><i><b><?php echo $senior_discount_quantity; ?></b></i></font></td> <td align="center"><font face="verdana" size="1" color="#000000"><i><b><?php echo $senior_discount_sku ?></b></i></font></td> <td><font face="verdana" size="1" color="#000000"><i><b><?php echo $senior_discount_description; ?></b></i></font></td> <td align="center"><font face="verdana" size="1" color="#000000"><i><b><?php echo $senior_discount_location; ?></b></i></font></td> <td align="right"><font face="verdana" size="1" color="#000000"><i><b>%<?php echo $senior_discount; ?></b></i></font></td> <td align="right"><font face="verdana" size="1" color="#000000"><i><b>%<?php echo $senior_discount; ?></b></i></font></td> </tr> <?php } // Query the Promotional Discount $promo_discount_query = mysql_query("SELECT * FROM invoice_entries, sku_codes WHERE invoice_entries.invoice_number = $invoice_number AND invoice_entries.sku_number = sku_codes.sku AND sku_codes.sku = 03-00") or die(mysql_error()); while($row = mysql_fetch_array($promo_discount_query)) { $promo_discount = $row['price_each']; $promo_discount_location = $row['location']; $promo_discount_description = $row['sku_description']; $promo_discount_quantity = $row['quantity']; $promo_discount_sku = $row['sku']; ?> <tr bgcolor="#f9c364"> <td align="center"><font face="verdana" size="1" color="#000000"><i><b><?php echo $promo_discount_quantity; ?></b></i></font></td> <td align="center"><font face="verdana" size="1" color="#000000"><i><b><?php echo $promo_discount_sku ?></b></i></font></td> <td><font face="verdana" size="1" color="#000000"><i><b><?php echo $promo_discount_description; ?></b></i></font></td> <td align="center"><font face="verdana" size="1" color="#000000"><i><b><?php echo $promo_discount_location; ?></b></i></font></td> <td align="right"><font face="verdana" size="1" color="#000000"><i><b>%<?php echo $promo_discount; ?></b></i></font></td> <td align="right"><font face="verdana" size="1" color="#000000"><i><b>%<?php echo $promo_discount; ?></b></i></font></td> </tr> <?php } // NEW CODE HERE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // Query Invoice records from tables : invoice_entries, sku_codes THAT ARE TAX EXEMPT! $query_invoice_entries = mysql_query("SELECT * FROM invoice_entries, sku_codes WHERE invoice_entries.invoice_number = $invoice_number AND invoice_entries.sku_number = sku_codes.sku AND sku_codes.sku != 01-00 AND invoice_entries.sku_number = sku_codes.sku AND sku_codes.sku != 02-00 AND invoice_entries.sku_number = sku_codes.sku AND sku_codes.sku != 03-00 AND sku_codes.sku_taxable = 0") or die(mysql_error()); // Math variable assignments $price_each_not_taxable_subtotal = 0; // Begin While Loop of invoice records while($row = mysql_fetch_array($query_invoice_entries)) { $quantity = $row['quantity']; $sku_number = $row['sku_number']; $location = $row['location']; $price_each = $row['price_each']; $sku_description = $row['sku_description']; $sku_taxable = $row['sku_taxable']; // Math, Number Format Variables $price_each_not_taxable_subtotal += ($quantity * $price_each); $price_each_not_taxable_subtotal_self = ($quantity * $price_each); ?> <tr bgcolor="#ffffff"> <td align="center"><font face="verdana" size="1" color="#000000"><?php echo $quantity; ?></font></td> <td align="center"><font face="verdana" size="1" color="#000000"><?php echo $sku_number; ?></font></td> <td align="left"><font face="verdana" size="1" color="#000000"><?php echo $sku_description; ?></font></td> <td align="center"><font face="verdana" size="1" color="#000000"><?php echo $location; ?></font></td> <td align="right"><font face="verdana" size="1" color="#000000">$<?php echo number_format($price_each,$decimals = 2, $dec_point = '.', $thousands_sep = ','); ?></font></td> <td align="right"><font face="verdana" size="1" color="#000000">$<?php echo number_format($price_each_not_taxable_subtotal_self,$decimals = 2, $dec_point = '.', $thousands_sep = ','); ?></font></td> </tr> <?php } // Query Invoice records from tables : invoice_entries, sku_codes THAT ARE NOT TAX EXEMPT! $query_invoice_entries = mysql_query("SELECT * FROM invoice_entries, sku_codes WHERE invoice_entries.invoice_number = $invoice_number AND invoice_entries.sku_number = sku_codes.sku AND sku_codes.sku != 01-00 AND invoice_entries.sku_number = sku_codes.sku AND sku_codes.sku != 02-00 AND invoice_entries.sku_number = sku_codes.sku AND sku_codes.sku != 03-00 AND sku_codes.sku_taxable = 1") or die(mysql_error()); // Math variable assignments $price_each_subtotal = 0; // Begin While Loop of invoice records while($row = mysql_fetch_array($query_invoice_entries)) { $quantity = $row['quantity']; $sku_number = $row['sku_number']; $location = $row['location']; $price_each = $row['price_each']; $sku_description = $row['sku_description']; $sku_taxable = $row['sku_taxable']; // Math, Number Format Variables $price_each_subtotal += ($quantity * $price_each); $price_each_subtotal_self = ($quantity * $price_each); ?> <tr bgcolor="#ffffff"> <td align="center"><font face="verdana" size="1" color="#000000"><?php echo $quantity; ?></font></td> <td align="center"><font face="verdana" size="1" color="#000000"><?php echo $sku_number; ?></font></td> <td align="left"><font face="verdana" size="1" color="#000000"><?php echo $sku_description; ?></font></td> <td align="center"><font face="verdana" size="1" color="#000000"><?php echo $location; ?></font></td> <td align="right"><font face="verdana" size="1" color="#000000">$<?php echo number_format($price_each,$decimals = 2, $dec_point = '.', $thousands_sep = ','); ?></font></td> <td align="right"><font face="verdana" size="1" color="#000000">$<?php echo number_format($price_each_subtotal_self,$decimals = 2, $dec_point = '.', $thousands_sep = ','); ?></font></td> </tr> <?php } // Total Mathematics // New Subtotal Math $non_taxable_subtotal = ($price_each_not_taxable_subtotal); // Subtotal Math $subtotal_no_deposit = ($price_each_subtotal); // Discounts $discount_1 = ($subtotal_no_deposit * $senior_discount); $discount_2 = ($subtotal_no_deposit * $promo_discount); $senior_discount_extract = ($subtotal_no_deposit - $discount_1); $promo_discount_extract = ($subtotal_no_deposit - $discount_2); $total_discounts = (($senior_discount_extract + $promo_discount_extract) - $subtotal_no_deposit); // Tax Math $subtotal_tax = ($total_discounts * 0.07); $deposit_tax = ($deposit * 0.07); // Identify $tax $tax = ($subtotal_tax); // Final Total Math $subtotal = ($total_discounts + $non_taxable_subtotal); $total = ($subtotal + $tax - $deposit); ?> <!-- / End invoice Entries SQL & Table Structure --> <!-- End table outside of the while loop --> <!-- Close entry table --> </table> <br /> <!-- Open Sub Total, Tax, Total Table --> <table border="0" align="right" cellspacing="1" cellpadding="3" width="30%" bordercolor="#000000" bgcolor="#000000"> <tr bgcolor="#ffffff"> <td width="15%" align="right"><font face="verdana" size="1" color="#000000">SUB TOTAL :</font></td> <td width="15%" align="right"><font face="verdana" size="1" color="#000000">$<?php echo number_format($subtotal,$decimals = 2, $dec_point = '.', $thousands_sep = ','); ?></font></td> </tr> <tr bgcolor="#ffffff"> <td align="right"><font face="verdana" size="1" color="#000000">TAX :</font></td> <td align="right"><font face="verdana" size="1" color="#000000">$<?php echo number_format($tax,$decimals = 2, $dec_point = '.', $thousands_sep = ','); ?></font></td> </tr> <tr bgcolor="#ffffff"> <td align="right"><font face="verdana" size="2" color="#000000"><b>TOTAL DUE :</b></font></td> <td align="right"><font face="verdana" size="2" color="#000000"><b>$<?php echo number_format($total,$decimals = 2, $dec_point = '.', $thousands_sep = ','); ?></b></font></td> </tr> </table> <br /><br /><br /><br /> <!-- / End Invoice Entries SQL & Table Structure -> <?php include("includes/footer.php"); ?>
  2. Ok, I wrote this program about a year ago, it worked great for the year until I found out that I had to exclude tax on certain sku numbers...... So now what I am trying to do is figure out how to exclude tax from certain elements in the total and subtotal. I started by adding a field to the sku_codes table in the db called sku_taxable, it is a field that either has a 1 or a 0 in it, 1 for taxable, 0 for not taxable. so now i'm trying to write a conditional statement but i dont think thats the best course of action to go by. Any help would be greatly appreciated on how to make this work, becuase i truely lost myself with this script. <?php $title = "View Invoice"; include("includes/header.php"); $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } $invoice_number = $_GET['id']; // Select MYSQL Database mysql_select_db("terra_elegante_operations", $con); // ALL QUERIES FOR CREDIT THAT NEEDS TO BE APPLIED // Query the deposit $deposit_query2 = mysql_query("SELECT * FROM invoice_entries, sku_codes WHERE invoice_entries.invoice_number = $invoice_number AND invoice_entries.sku_number = sku_codes.sku AND sku_codes.sku = 01-00") or die(mysql_error()); if ($row = mysql_fetch_array($deposit_query2)) { $deposit = $row['price_each']; } else { $deposit = 0; } // Query the (Senior Citizen Discount - 01-02) $senior_discount_query_2 = mysql_query("SELECT * FROM invoice_entries, sku_codes WHERE invoice_entries.invoice_number = $invoice_number AND invoice_entries.sku_number = sku_codes.sku AND sku_codes.sku = 01-02") or die(mysql_error()); if ($row = mysql_fetch_array($senior_discount_query_2)) { $senior_discount = $row['price_each']; } else { $senior_discount = 0; } // Query the (Promotional Discount - 03-00) $promo_discount_query_2 = mysql_query("SELECT * FROM invoice_entries, sku_codes WHERE invoice_entries.invoice_number = $invoice_number AND invoice_entries.sku_number = sku_codes.sku AND sku_codes.sku = 03-00") or die(mysql_error()); if ($row = mysql_fetch_array($promo_discount_query_2)) { $promo_discount = $row['price_each']; } else { $promo_discount = 0; } // / END ALL QUERIES FOR CREDIT THAT NEEDS TO BE APPLIED // Query invoice number $query_client_invoice = mysql_query("SELECT * from client_invoices where invoice_number = $invoice_number"); // Assign Variables from client_invoices table. $row = mysql_fetch_array($query_client_invoice); $account_number = $row['account_number']; $invoice_date = $row['invoice_date']; $invoice_status = $row['invoice_status']; $due_date = $row['due_date']; // Query Client Information $query_client_information = mysql_query("SELECT * FROM client_information where account_number = $account_number"); // Assign Variables from client_information table. $row = mysql_fetch_array($query_client_information); $name_first = $row['name_first']; $name_last = $row['name_last']; $address = $row['address']; $city = $row['city']; $state = $row['state']; $zipcode = $row['zipcode']; $telephone = $row['telephone']; $telephone_alt = $row['telephone_alt']; $email = $row['email']; ?> <table border="0" cellspacing="0" cellpadding="0" width="100%" bordercolor="#000000"> <tr> <td><font face="verdana" size="2" color="#000000"><b><?php echo "<a class='bubble_nav' href='edit_invoice.php?id=$invoice_number'>EDIT INVOICE</a>"; ?> | <?php echo "<a class='bubble_nav' href='print_invoice.php?id=$invoice_number' target='_blank'>PRINT INVOICE</a>"; ?></b></font></td> </tr> </table> <!-- Invoice Heading - Account #, Invoice #, Name, Address, Telephone #'s --> <br /> <table border="0" cellspacing="0" cellpadding="2" width="100%" bordercolor="#000000"> <tr> <td colspan="4" align="left"><font face="verdana" size="3" color="#000000"><b><u>Invoice Date: <?php echo $invoice_date; ?></u></b></font></td> </tr> <td width="20%"><font face="verdana" size="2" color="#000000">Account Number:</font></td> <td width="40%"><font face="verdana" size="2" color="#000000"><?php echo "<a class=\"bubble_nav\" href='show_client.php?id=$account_number'>$account_number</a\>"; ?></font></td> <td width="20%"><font face="verdana" size="2" color="#000000">Telephone</font></td> <td width="20%"><font face="verdana" size="2" color="#000000"><?php echo $telephone; ?></font></td> </tr> <tr> <td><font face="verdana" size="2" color="#000000">Invoice Number:</font></td> <td><font face="verdana" size="2" color="#000000"><?php echo $invoice_number; ?></font></td> <td><font face="verdana" size="2" color="#000000">Telephone Alt</font></td><td><font face="verdana" size="2" color="#000000"><?php echo $telephone_alt ?></font></td> </tr> <tr> <td colspan="2"><font face="verdana" size="2" color="#000000"><br /><?php echo $name_last; ?> , <?php echo $name_first; ?></font></td> <td align="left" valign="bottom" colspan="2" rowspan="3"><font face="verdana" size="3" color="#000000"><b>Status: <?php echo $invoice_status ?></b><br />Due Date:<?php echo $due_date; ?></font></td> </tr> <tr> <td colspan="2"><font face="verdana" size="2" color="#000000"><?php echo $address ?></font></td> </tr> <tr> <td colspan="2"><font face="verdana" size="2" color="#000000"><?php echo $city; ?>, <?php echo $state; ?> <?php echo $zipcode; ?></font></td> </tr> </table> <!-- / End Invoice Heading --> <!-- Begin Invoice Entries SQL & Table Structure --> <br /><br /><br /> <!-- Out of the while loop / Top of table --> <table bgcolor="#000000" border="0" cellspacing="1" cellpadding="2" width="100%" bordercolor="#000000"> <tr bgcolor="#CCCCCC"> <td align="center" width="5%"><font face="verdana" size="2" color="#000000"><b>QTY</b></font></td> <td align="center" width="10%"><font face="verdana" size="2" color="#000000"><b>SKU</b></font></td> <td align="center" width="30%"><font face="verdana" size="2" color="#000000"><b>DESCRIPTION</b></font></td> <td align="center" width="25%"><font face="verdana" size="2" color="#000000"><b>LOCATION</b></font></td> <td align="center"width="15%"><font face="verdana" size="2" color="#000000"><b>EACH</b></font></td> <td align="center" width="15%"><font face="verdana" size="2" color="#000000"><b>TOTAL</b></font></td> </tr> <?php // Query the deposit $deposit_query = mysql_query("SELECT * FROM invoice_entries, sku_codes WHERE invoice_entries.invoice_number = $invoice_number AND invoice_entries.sku_number = sku_codes.sku AND sku_codes.sku = 01-00") or die(mysql_error()); while($row = mysql_fetch_array($deposit_query)) { $deposit = $row['price_each']; $deposit_location = $row['location']; $deposit_description = $row['sku_description']; $deposit_quantity = $row['quantity']; $deposit_sku = $row['sku']; ?> <tr bgcolor="#c2f48c"> <td align="center"><font face="verdana" size="1" color="#000000"><i><b><?php echo $deposit_quantity; ?></b></i></font></td> <td align="center"><font face="verdana" size="1" color="#000000"><i><b><?php echo $deposit_sku ?></b></i></font></td> <td><font face="verdana" size="1" color="#000000"><i><b><?php echo $deposit_description; ?></b></i></font></td> <td align="center"><font face="verdana" size="1" color="#000000"><i><b><?php echo $deposit_location; ?></b></i></font></td> <td align="right"><font face="verdana" size="1" color="#000000"><i><b>$<?php echo $deposit; ?></b></i></font></td> <td align="right"><font face="verdana" size="1" color="#000000"><i><b>$<?php echo $deposit; ?></b></i></font></td> </tr> <?php } // Query the Senior Discount $senior_discount_query = mysql_query("SELECT * FROM invoice_entries, sku_codes WHERE invoice_entries.invoice_number = $invoice_number AND invoice_entries.sku_number = sku_codes.sku AND sku_codes.sku = 02-00") or die(mysql_error()); while($row = mysql_fetch_array($senior_discount_query)) { $senior_discount = $row['price_each']; $senior_discount_location = $row['location']; $senior_discount_description = $row['sku_description']; $senior_discount_quantity = $row['quantity']; $senior_discount_sku = $row['sku']; ?> <tr bgcolor="#f8ec66"> <td align="center"><font face="verdana" size="1" color="#000000"><i><b><?php echo $senior_discount_quantity; ?></b></i></font></td> <td align="center"><font face="verdana" size="1" color="#000000"><i><b><?php echo $senior_discount_sku ?></b></i></font></td> <td><font face="verdana" size="1" color="#000000"><i><b><?php echo $senior_discount_description; ?></b></i></font></td> <td align="center"><font face="verdana" size="1" color="#000000"><i><b><?php echo $senior_discount_location; ?></b></i></font></td> <td align="right"><font face="verdana" size="1" color="#000000"><i><b>%<?php echo $senior_discount; ?></b></i></font></td> <td align="right"><font face="verdana" size="1" color="#000000"><i><b>%<?php echo $senior_discount; ?></b></i></font></td> </tr> <?php } // Query the Promotional Discount $promo_discount_query = mysql_query("SELECT * FROM invoice_entries, sku_codes WHERE invoice_entries.invoice_number = $invoice_number AND invoice_entries.sku_number = sku_codes.sku AND sku_codes.sku = 03-00") or die(mysql_error()); while($row = mysql_fetch_array($promo_discount_query)) { $promo_discount = $row['price_each']; $promo_discount_location = $row['location']; $promo_discount_description = $row['sku_description']; $promo_discount_quantity = $row['quantity']; $promo_discount_sku = $row['sku']; ?> <tr bgcolor="#f9c364"> <td align="center"><font face="verdana" size="1" color="#000000"><i><b><?php echo $promo_discount_quantity; ?></b></i></font></td> <td align="center"><font face="verdana" size="1" color="#000000"><i><b><?php echo $promo_discount_sku ?></b></i></font></td> <td><font face="verdana" size="1" color="#000000"><i><b><?php echo $promo_discount_description; ?></b></i></font></td> <td align="center"><font face="verdana" size="1" color="#000000"><i><b><?php echo $promo_discount_location; ?></b></i></font></td> <td align="right"><font face="verdana" size="1" color="#000000"><i><b>%<?php echo $promo_discount; ?></b></i></font></td> <td align="right"><font face="verdana" size="1" color="#000000"><i><b>%<?php echo $promo_discount; ?></b></i></font></td> </tr> <?php } // Query Invoice records from tables : invoice_entries, sku_codes $query_invoice_entries = mysql_query("SELECT * FROM invoice_entries, sku_codes WHERE invoice_entries.invoice_number = $invoice_number AND invoice_entries.sku_number = sku_codes.sku AND sku_codes.sku != 01-00 AND invoice_entries.sku_number = sku_codes.sku AND sku_codes.sku != 02-00 AND invoice_entries.sku_number = sku_codes.sku AND sku_codes.sku != 03-00") or die(mysql_error()); // Math variable assignments $price_each_subtotal = 0; // Begin While Loop of invoice records while($row = mysql_fetch_array($query_invoice_entries)) { $quantity = $row['quantity']; $sku_number = $row['sku_number']; $location = $row['location']; $price_each = $row['price_each']; $sku_description = $row['sku_description']; $sku_taxable = $row['sku_taxable']; if ($sku_taxable=1) {$taxable;} else if ($sku_taxable=0) {$not_taxable;} // Math, Number Format Variables $price_each_subtotal += ($quantity * $price_each); $price_each_subtotal_self = ($quantity * $price_each); ?> <tr bgcolor="#ffffff"> <td align="center"><font face="verdana" size="1" color="#000000"><?php echo $quantity; ?></font></td> <td align="center"><font face="verdana" size="1" color="#000000"><?php echo $sku_number; ?></font></td> <td align="left"><font face="verdana" size="1" color="#000000"><?php echo $sku_description; ?></font></td> <td align="center"><font face="verdana" size="1" color="#000000"><?php echo $location; ?></font></td> <td align="right"><font face="verdana" size="1" color="#000000">$<?php echo number_format($price_each,$decimals = 2, $dec_point = '.', $thousands_sep = ','); ?></font></td> <td align="right"><font face="verdana" size="1" color="#000000">$<?php echo number_format($price_each_subtotal_self,$decimals = 2, $dec_point = '.', $thousands_sep = ','); ?></font></td> </tr> <?php } // Total Mathematics // New Subtotal Math // Subtotal Math $subtotal_no_deposit = ($price_each_subtotal); // Discounts $discount_1 = ($subtotal_no_deposit * $senior_discount); $discount_2 = ($subtotal_no_deposit * $promo_discount); $senior_discount_extract = ($subtotal_no_deposit - $discount_1); $promo_discount_extract = ($subtotal_no_deposit - $discount_2); $total_discounts = (($senior_discount_extract + $promo_discount_extract) - $subtotal_no_deposit); // Tax Math $subtotal_tax = ($total_discounts * 0.07); $deposit_tax = ($deposit * 0.07); // Identify $tax $tax = ($subtotal_tax); // Final Total Math $subtotal = ($total_discounts); $total = ($subtotal + $tax - $deposit); ?> <!-- / End invoice Entries SQL & Table Structure --> <!-- End table outside of the while loop --> <!-- Close entry table --> </table> <br /> <!-- Open Sub Total, Tax, Total Table --> <table border="0" align="right" cellspacing="1" cellpadding="3" width="30%" bordercolor="#000000" bgcolor="#000000"> <tr bgcolor="#ffffff"> <td width="15%" align="right"><font face="verdana" size="1" color="#000000">SUB TOTAL :</font></td> <td width="15%" align="right"><font face="verdana" size="1" color="#000000">$<?php echo number_format($subtotal,$decimals = 2, $dec_point = '.', $thousands_sep = ','); ?></font></td> </tr> <tr bgcolor="#ffffff"> <td align="right"><font face="verdana" size="1" color="#000000">TAX :</font></td> <td align="right"><font face="verdana" size="1" color="#000000">$<?php echo number_format($tax,$decimals = 2, $dec_point = '.', $thousands_sep = ','); ?></font></td> </tr> <tr bgcolor="#ffffff"> <td align="right"><font face="verdana" size="2" color="#000000"><b>TOTAL DUE :</b></font></td> <td align="right"><font face="verdana" size="2" color="#000000"><b>$<?php echo number_format($total,$decimals = 2, $dec_point = '.', $thousands_sep = ','); ?></b></font></td> </tr> </table> <br /><br /><br /><br /> <!-- / End Invoice Entries SQL & Table Structure -> <?php include("includes/footer.php"); ?>
  3. it wont be empty using SUM AS $variable though, it will return as 1 reguardless if data is there or not, isnt that why im having this problem dark? or am i missing something completely different now lol
  4. This code works, but wow, its ridiclious <!-- Q1 CYCLE OIL BREAKDOWN --> <td width="25%" valign="top"><font face="verdana" size="1"><b>Q1 Cycle Oil</b><br />$ <?php $q1_cycle_oil_check = "SELECT * FROM expense_fuel WHERE fuel_code = 017 AND year = $exp_year AND month between 01 and 03"; $q1_cycle_oil_check_results = mysql_query($q1_cycle_oil_check) or die(mysql_error()); $q1_cycle_oil_check_count = mysql_num_rows($q1_cycle_oil_check_results); if ($q1_cycle_oil_check_count > 0) { $q1_cycle_oil = "SELECT SUM(amount) AS q1_cycle_oil_exp FROM expense_fuel WHERE fuel_code = 017 AND year = $exp_year AND month between 01 and 03"; $q1_cycle_oil_results = mysql_query($q1_cycle_oil) or die(mysql_error()); while($row = mysql_fetch_array($q1_cycle_oil_results)) { echo $row['q1_cycle_oil_exp']; } } else { echo "0.00"; } ?> </font></td> <!-- / END / Q1 CYCLE OIL BREAKDOWN -->
  5. thats why its working the way i have it, but its soo not efficiant. i have it set to check without a sum, if theres anything there, then add the sum all up, if theres nothing there then print 0.00 the concept is good i guess becuase it works, but the procedure is just a mess lol
  6. yeah pfmabismad thats what i just was saying something about lol, sorry u responded while i was responding =) did i just noob jessicas code up when i put it in there, or did she make a mistake with it? because what she wrote is way over my comprehension level lol.
  7. i mean is there a reason why this works and the other way doesnt? i was reading about mysql_num_rows returning always as 1 when used as a sum. so if i only have 1 entry in the db for cycle oil "witch i prob always will becuase i buy it in bulk at the begining of the year and that ususally lasts me all season" then for the other quarters there shouldnt be anything, except on the annual report.
  8. i posted it, thats what came out under cycle oil, it showed the query code, not an error error sorry
  9. an error lol. im trying to understand how you wrote that, sucks being a noob at php Q1 Cycle Oil $ Query: SELECT SUM(amount) AS q1_cycle_oil_exp FROM expense_fuel WHERE fuel_code = 017 AND year = 2017 AND month between 01 and 03 result: Array ( [0] => [q1_cycle_oil_exp] => )
  10. <!-- / END / Q2 DIESEL BREAKDOWN --> <!-- Q3 DIESEL BREAKDOWN --> <td width="25%" valign="top"><font face="verdana" size="1"><b>Q3 Diesel</b><br />$ <?php $q3_diesel = "SELECT SUM(amount) AS q3_diesel_exp FROM expense_fuel WHERE fuel_code = 001 AND year = $exp_year AND month between 07 and 09"; $q3_diesel_results = mysql_query($q3_diesel) or die(mysql_error()); while($row = mysql_fetch_array($q3_diesel_results)) { echo $row['q3_diesel_exp']; } ?> </font></td> <!-- / END / Q3 DIESEL BREAKDOWN --> this prints the sum fine no problem if there is 1, if theres none, then it just shows up blank, how would i make it show up as 0.00 echoed without an if else? im really really confused
  11. yeah that works fine it echos the sum no problem if theres entries. but i want it to print 0.00 if theres no entries instead of just showing up blank. is there a diff way to do that besides if else?
  12. like the way i had it origionally? im not sure how to do it like you mean. i dont like the way i have it either lol an extra query for nothing lol. can you show me what you mean jessica? i want to echo the sum nomatter what it is, but the select sum(amount) if its 0 is showing up as nothing, not printing the else 0.00 statment
  13. Jessica you were right, it was because i was calling a sum. i added a regular query first to check to see if it was there, then in my conditional i used the sum query and the else as the 0.00 <!-- Q1 CYCLE OIL BREAKDOWN --> <td width="25%" valign="top"><font face="verdana" size="1"><b>Q1 Cycle Oil</b><br />$ <?php $q1_cycle_oil_check = "SELECT * FROM expense_fuel WHERE fuel_code = 017 AND year = $exp_year AND month between 01 and 03"; $q1_cycle_oil_check_results = mysql_query($q1_cycle_oil_check) or die(mysql_error()); $q1_cycle_oil_check_count = mysql_num_rows($q1_cycle_oil_check_results); if ($q1_cycle_oil_check_count > 0) { $q1_cycle_oil = "SELECT SUM(amount) AS q1_cycle_oil_exp FROM expense_fuel WHERE fuel_code = 017 AND year = $exp_year AND month between 01 and 03"; $q1_cycle_oil_results = mysql_query($q1_cycle_oil) or die(mysql_error()); while($row = mysql_fetch_array($q1_cycle_oil_results)) { echo $row['q1_cycle_oil_exp']; } } else { echo "0.00"; } ?> </font></td> <!-- / END / Q1 CYCLE OIL BREAKDOWN --> thank you for the help guys =)
  14. I don't know how to check them in phpmyadmin, never did that before. i think jessica is right, im using a sum to count the values of a specific field, but does it really matter becuase all my condition is asking is that if it finds anything to print the sum, if it doesnt find anything just print 0.00 im confused =(
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.