Jump to content

invoicing question


bhavin_85

Recommended Posts

hi peps

 

i have been using query strings to carry data from 1 page to another in my invoice section...im having a bit of trouble with it though...firstly i have run a query which takes the cust_id and getsthe invoice details from the database by matching invoice_id in 2 tables and item_id in 2 tables...which all have the same cust_id

 

heres the table structure:

Invoices:                Invoice_items:              Item:

 

invoice_id(*)--+        invoice_item_id(*)    +---- item_id(*)

cust_id          +----  invoices.invoice_id    |    item_name

                              item.item_id      ----+

                            description

                            weight

                            price

 

$sql="SELECT a.cust_id, a.invoice_id, c.item_name, b.description, b.weight, b.price, b.date
FROM invoices a
    INNER JOIN invoice_items b ON a.invoice_id = b.invoices_invoice_id
    INNER JOIN item c ON b.item_item_id = c.item_id
WHERE a.cust_id = '$id'";
$query=mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_assoc($query)) {
$cust_id = $row['cust_id'];
echo $row["cust_id"]; 
echo '<a href="http://localhost/PBL/invoice1.php?cust_id='.$cust_id.'">id</a></br>';

$date = $row['date'];
echo $row["date"];
echo '<a href="http://localhost/PBL/invoice1.php?date='.$date.'">date</a>'	;

 

so far in the database ive entered

Items table: ring, watch and necklac

Invoice Table:  1 invoice in the invoice table(incoice_id = 1, cust_id=4)

Invoice_items:  2 items associated with 1 invoice(invoice_item_id=1, invoices_invoices_id=1, item_item_id=1, weight=8, price=88, date=2007-02-27) and (invoice_item_id=2, invoices_invoices_id=1, item_item_id=2, weight=null, price=650, date=2007-02-27)

 

i need this first page to show the invoice dates then make each date linkable to a new page which shows all the invoice details, i know how to make it linkabl i jsut cant figure out why its showing 2 of the same dates! is there soemthing wrong with my query??

 

thakns 4 ur help soorry 4 the huge write up just figured id get everything i need in here :)

Link to comment
https://forums.phpfreaks.com/topic/40375-invoicing-question/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.