Forum Moderators: coopster

Message Too Old, No Replies

Select tag pre defined

I want the select tag to select the current status

         

Twisted Mind

10:43 am on Oct 28, 2005 (gmt 0)

10+ Year Member



Hi i want to know how it is possible to make a <select></select> tag to get the current status from a mysql database and display that one...
like the database says 3 and the list has 1-10 that it displays 3 on opening of te page

dmmh

12:38 pm on Oct 31, 2005 (gmt 0)

10+ Year Member



lol

Twisted Mind

12:39 pm on Oct 31, 2005 (gmt 0)

10+ Year Member



can i do something about this exept editting php.ini?

Notice: Undefined variable: order_status_selector in D:\Fluke_Mambo\includes\functions.php on line 4

Twisted Mind

12:47 pm on Oct 31, 2005 (gmt 0)

10+ Year Member



omg i need exactly the same script for order_status_it... but now it turns out blanco with the welcome message again :(

Twisted Mind

12:49 pm on Oct 31, 2005 (gmt 0)

10+ Year Member



this is the source code in html :S

Welcome it-confirmer<br><br>
<table>

<form name="change_order_id" method="post" action="components/com_confirmation/confirm_order_status_update.php">

</form>
</table>

dmmh

12:50 pm on Oct 31, 2005 (gmt 0)

10+ Year Member



you can safely remove the first . here:

$order_status_selector .= "<select name=\"order_status\" size=\"1\">\n";

so:

$order_status_selector = "<select name=\"order_status\" size=\"1\">\n";

should work with it though....leave the rest of the dots down the function intact though

dmmh

12:52 pm on Oct 31, 2005 (gmt 0)

10+ Year Member



in that case, your query, is it selecting anything at all?

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;

Twisted Mind

12:52 pm on Oct 31, 2005 (gmt 0)

10+ Year Member



hmm i think u cant help me w ith this probally something diff3erent in user

Twisted Mind

12:55 pm on Oct 31, 2005 (gmt 0)

10+ Year Member



indeed thats what i thought has 0 results probally becouse its a totally different user :)

dmmh

12:55 pm on Oct 31, 2005 (gmt 0)

10+ Year Member



ok :)

Twisted Mind

12:57 pm on Oct 31, 2005 (gmt 0)

10+ Year Member



i think i found it financeconf is the only one from the usa that means something!= must be == or the other way

Twisted Mind

12:58 pm on Oct 31, 2005 (gmt 0)

10+ Year Member



WHERE order_id NOT IN (select order_id FROM mos_pshop_order_user_info WHERE country ='$mycountry')";

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

Twisted Mind

12:59 pm on Oct 31, 2005 (gmt 0)

10+ Year Member



only manager now this one is only a little bit harder becouse it needs filtered by departement too...

but thats just the wHERE tag from my own script thanks dude

Twisted Mind

1:03 pm on Oct 31, 2005 (gmt 0)

10+ Year Member



and another query to define the logged in users departement :)

dmmh

1:04 pm on Oct 31, 2005 (gmt 0)

10+ Year Member



It had already crossed my mind, but I neglected it, thinking you would have at least the queries ok :p

dmmh

1:05 pm on Oct 31, 2005 (gmt 0)

10+ Year Member



so it is working now?

Twisted Mind

1:07 pm on Oct 31, 2005 (gmt 0)

10+ Year Member



hmm a little problem but ill find it out i think :)

Twisted Mind

1:10 pm on Oct 31, 2005 (gmt 0)

10+ Year Member



it was no problem just stupid from me... the users atm dont have a departement lol

Twisted Mind

1:13 pm on Oct 31, 2005 (gmt 0)

10+ Year Member



i do have an error

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());?>

dmmh

1:20 pm on Oct 31, 2005 (gmt 0)

10+ Year Member



well ofcourse, you are using a different table for the WHERE clause.....

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'

Twisted Mind

1:21 pm on Oct 31, 2005 (gmt 0)

10+ Year Member



thought it could work becouse it worked in the other query :)

Twisted Mind

1:28 pm on Oct 31, 2005 (gmt 0)

10+ Year Member



thanks u made only 1 tiny error in table mos_users u named id user_id :) but i made that one loads of times becouse i do php mysql 2 months now

Twisted Mind

2:09 pm on Oct 31, 2005 (gmt 0)

10+ Year Member



another bug found in function u call the name order_status has to be different for all 3 order_status_it order_status_manager order_status_finance

but im lazy so ill copy them and make 3 of them

dmmh

3:41 pm on Oct 31, 2005 (gmt 0)

10+ Year Member



omg dood, do you even know how functions work?

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

Twisted Mind

7:05 am on Nov 1, 2005 (gmt 0)

10+ Year Member



I dont know how functions work but u are saying that it worked okay yesterday? becouse it actually dind :) the name of the field was order_status

Twisted Mind

7:06 am on Nov 1, 2005 (gmt 0)

10+ Year Member



and indeed i dont know functions :)

Twisted Mind

7:10 am on Nov 1, 2005 (gmt 0)

10+ Year Member



strange changed it back shows order_status_manager when script says $row['order_status_it']

Twisted Mind

7:11 am on Nov 1, 2005 (gmt 0)

10+ Year Member



nvm that was my mistake now it is named order_status...

Twisted Mind

7:30 am on Nov 1, 2005 (gmt 0)

10+ Year Member



Hey what you just explained is not what im looking for i just saw teh form displays it allrite but one problem
THE name of the select tag stays order_status
and it should be exmpl: order_status_finance

dmmh

9:10 am on Nov 1, 2005 (gmt 0)

10+ Year Member



you could always do it like this...

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');

;)

Twisted Mind

9:19 am on Nov 1, 2005 (gmt 0)

10+ Year Member



i will check it out :P
This 94 message thread spans 4 pages: 94