PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Addos
Forum Contributor
Posts: 305 Joined: Mon Jan 17, 2005 4:13 pm
Post
by Addos » Mon Jul 16, 2007 8:45 am
Hi,
I’m not sure how to pass two arguments to my query using the following:
Code: Select all
<a href="paybycheque.php?order_ID=<?php echo($row_rsCWOrder["order_ID"]);?>&cst_ID=<?php echo($row_rsCWOrder["order_CustomerID"]);?>">Change</a>
And this is where I’m passing this to but I’m getting and error.
Can anyone tell/show me what I need to do?
Thanks
B
Code: Select all
<?php
$colname_GetCustomer = "1";
if (isset($_GET['cst_ID'])) {
$colname_GetCustomer = (get_magic_quotes_gpc()) ? $_GET['cst_ID'] : addslashes($_GET['cst_ID']);
}
mysql_select_db($database_*****, $*****);
$query_GetCustomer = sprintf("SELECT * FROM tbl_customers, tbl_orders
WHERE order_ID = '%s'
AND cst_ID = '%s'", $colname_GetCustomer);
$GetCustomer = mysql_query($query_GetCustomer, $batchelors) or die(mysql_error());
$row_GetCustomer = mysql_fetch_assoc($GetCustomer);
$totalRows_GetCustomer = mysql_num_rows($GetCustomer);
?>
Last edited by
Addos on Mon Jul 16, 2007 3:08 pm, edited 1 time in total.
Begby
Forum Regular
Posts: 575 Joined: Wed Dec 13, 2006 10:28 am
Post
by Begby » Mon Jul 16, 2007 8:52 am
And the error is?
boo
Forum Commoner
Posts: 42 Joined: Mon Jul 02, 2007 11:30 am
Location: NY
Post
by boo » Mon Jul 16, 2007 9:21 am
I dont see where you are passing order_ID into the SQL statement.
Here you are getting the cst_id value but you are not doing the same for the order_ID
Code: Select all
$colname_GetCustomer = "1";
if (isset($_GET['cst_ID'])) {
$colname_GetCustomer = (get_magic_quotes_gpc()) ? $_GET['cst_ID'] : addslashes($_GET['cst_ID']);
}
Addos
Forum Contributor
Posts: 305 Joined: Mon Jan 17, 2005 4:13 pm
Post
by Addos » Mon Jul 16, 2007 10:33 am
"I dont see where you are passing order_ID into the SQL statement."
Yep that's where I'm stuck as i know only how to pass one value and not the two together.
Thanks for your reply.
B
dxm
Forum Newbie
Posts: 8 Joined: Fri Jun 29, 2007 5:18 pm
Location: Wales
Post
by dxm » Mon Jul 16, 2007 12:07 pm
You can get and check both the variables passed through the URL like this, then it's just adding it to your query the same way you did with
$colname_GetCustomer .
Code: Select all
if (isset($_GET['cst_ID']) && isset($_GET['order_ID'])) {
$colname_GetCustomer = (get_magic_quotes_gpc()) ? $_GET['cst_ID'] : addslashes($_GET['cst_ID']);
$colname_GetOrder = (get_magic_quotes_gpc()) ? $_GET['order_ID'] : addslashes($_GET['order_ID']);
}
Try this and post back with any errors or warnings if you get them.
boo
Forum Commoner
Posts: 42 Joined: Mon Jul 02, 2007 11:30 am
Location: NY
Post
by boo » Mon Jul 16, 2007 12:24 pm
dxm wrote:
Code: Select all
if (isset($_GET['cst_ID']) && isset($_GET['order_ID'])) {
$colname_GetCustomer = (get_magic_quotes_gpc()) ? $_GET['cst_ID'] : addslashes($_GET['cst_ID']);
$colname_GetOrder = (get_magic_quotes_gpc()) ? $_GET['order_ID'] : addslashes($_GET['order_ID']);
}
Along with the code above you will need to do this to get in into your SQL statement
Code: Select all
$query_GetCustomer = sprintf("SELECT * FROM tbl_customers, tbl_orders
WHERE order_ID = '%s'
AND cst_ID = '%s'", $colname_GetOrder , $colname_GetCustomer);
RobertGonzalez
Site Administrator
Posts: 14293 Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA
Post
by RobertGonzalez » Mon Jul 16, 2007 12:38 pm
Keep in mind that the conditional is checking && which means if one of the other is not set then the entire condition will evaluate to false and will not fire. Is that what you want?
Addos
Forum Contributor
Posts: 305 Joined: Mon Jan 17, 2005 4:13 pm
Post
by Addos » Mon Jul 16, 2007 3:07 pm
Thank you very much. Works a treat.