Jump to content

[SOLVED] Query string help!


bhavin_85

Recommended Posts

hey guys

 

im having some trouble with query strings....im making an invoice page which on the first page shows all the invoice dates then when the date is clicked on shows the invoice infomation.

 

i think query strings are the best way to do it...ive had a go at writtin the code but dont know what im doing wrong  ???

 

<?
session_start();
if ( empty($_SESSION['username'])){
header("location:default.php");
exit;
}
$id=$_SESSION['cust_id'];

include ('config.php');

$sql=$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 = $GET['cust_id'];
$invoice_id = $GET['invoice_id'];
$item_name = $GET['item_name'];
$description = $GET['description'];
$weight = $GET['weight'];
$price = $GET['price'];
$date = $GET['date'];

}
?>

 

any ideas?

Link to comment
https://forums.phpfreaks.com/topic/40350-solved-query-string-help/
Share on other sites

ive made a bit of progress...with this

 

but i still dont understnad if im doing it right....i need the first page to display invoice dates depending on the customer_id...then when the user clicks on the link it will open the details of that invoice

 

<?
session_start();
if ( empty($_SESSION['username'])){
header("location:default.php");
exit;
}
$id=$_SESSION['cust_id'];

include ('config.php');

$sql=$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>');
} 
?>

 

any 1 know how to do this?

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.