Forum Moderators: coopster
try this:
$query = "SELECT order_id,order_status_it,order_status_manager,order_status_finance FROM $table
WHERE order_id NOT IN (select order_id FROM mos_pshop_order_user_info WHERE country ='$mycountry')";
$result = mysql_query($query) or die ("Error in query: $query " . mysql_error());
$num_results = mysql_num_rows($result);
echo 'number of results:'.$num_results;
should be
WHERE order_id IN (select order_id FROM mos_pshop_order_user_info WHERE country ='$mycountry')";
fconf wasnt allowed to see any orders i just found out becouse it has to be from nl for that :p
Error in query: SELECT order_id,order_status_it,order_status_manager,order_status_finance FROM mos_pshop_orders WHERE mos_users.id = mos_pshop_orders.user_id AND mos_users.country = 'NLD' AND mos_users.departement ='1' Unknown table 'mos_users' in where clause
this is query
$query = "SELECT order_id,order_status_it,order_status_manager,order_status_finance FROM $table
WHERE $usertable.id = mos_pshop_orders.user_id
AND $usertable.country = '$mycountry'
AND $usertable.departement ='$mydepartement'";
$result = mysql_query($query) or die ("Error in query: $query " . mysql_error());?>
you are looking in mos_pshop_orders and are using a clause which looks for #*$! in mos_users, this is impossible, at least i n the way you are doing it now
you need something like:
SELECT * FROM mos_pshop_orders
INNER JOIN mos_users
ON mos_users.user_id = mos_pshop_orders.user_id
WHERE mos_users.country = 'NLD' AND mos_users.departement ='1'
the $order_status variable holds a value passed to the function by another variable...
say $order_status_finance = 'cancelled'
now if you do a:
echo func_order_status_selector($order_status_finance);
this is basically the same as saying:
echo func_order_status_selector('cancelled');
since we have called the function, the $order_status variable INSIDE THE FUNCTION will now have a value of 'cancelled'.
It doesnt matter what it is named, you could rename it to $dog_poo and $dog_poo would still have a value of 'cancelled'
so to make a long story short, in your case you can simply call the function multiple times, passing it the values of order_status_it, order_status_manager or order_status_finance
all we do is pass a string to the function and see if it matches one of the items in the array inside the function, then pre-select the option
change the first 2 lines of the function from:
function func_order_status_selector($order_status){
$order_status_selector = "<select name=\"order_status\" size=\"1\">\n";
TO:
function func_order_status_selector($order_status, $select_name){
$order_status_selector = "<select name=\"$select_name\" size=\"1\">\n";
then call the function inside your script like:
echo func_order_status_selector($row['order_status_it'], 'order_status_it');
you see what it does? the first argument passed to the function is the value for the current id (cancelled etc) and the second is a string, the name we want to give to the HTML select.
This way you can re-use the function for all 3 scenarios.
Just pass it the correct name for the select and the correct value for the current id :)
examples:
1: echo func_order_status_selector($row['order_status_finance'], 'order_status_finance');
2: echo func_order_status_selector($row['order_status_manager'], 'order_status_finance');
3: echo func_order_status_selector($row['order_status_it'], 'order_status_it');
;)