mySQL- SELECT needs a value comming from an array
Posted: Tue Jul 26, 2005 4:13 am
Hi there,
lets say I have a working script wich gets a value form a mysql table and uses this value in another SELECT. Besides the value comes from a $_REQUEST (form).
The table strFields:
The query:
I get the value I need with this chunk of code:
As you can see, in $classid now is the value '6'
Only for the record:
I need to use that value in another SELECT wich is here:
So far everything is working properly. But here's my problem:
What if the $fieldnames[3] itself is an array. Lets say, somebody insert a comma-separated list in his form and the mysql-table would look like this:
With this chunk I could get the values from that list into a new array:
the echo outputs this, wich is correct.
0 is 6
1 is 7
2 is 8
3 is 9
8
So up to here I have the values in my array. But still I need to use any of that figures in my SELECT. How could this be done?
lets say I have a working script wich gets a value form a mysql table and uses this value in another SELECT. Besides the value comes from a $_REQUEST (form).
The table strFields:
Code: Select all
|---------------|------------------|---------------------|
| ID | strFilename | strFields |
|---------------|------------------|---------------------|
| 1 | shop_pref | €|16|german|6 |Code: Select all
SELECT strFields from "e;.VIEW_PREFS_TABLE."e; where strFilename = 'shop_pref'
....Code: Select all
$fieldnames = explode("e;|"e;,$DB_WE->f("e;strFields"e;));
$classid= $fieldnamesї3];Only for the record:
I need to use that value in another SELECT wich is here:
Code: Select all
$sqlOo = "e;SELECT "e;.OBJECT_X_TABLE."e;$classid.input_shoptitle as obTitle,"e;.OBJECT_X_TABLE."e;$classid.OF_ID as obID,"e;.SHOP_TABLE."e;.IntArticleID as aID,"e;.SHOP_TABLE."e;.IntOrderID as oID, DATE_FORMAT("e;.SHOP_TABLE."e;.DateOrder, '%d.%m.%Y - %H:%m:%s') as procd,"e;.SHOP_TABLE."e;.Price * "e;.SHOP_TABLE."e;.IntQuantity as sumt, DATE_FORMAT("e;.SHOP_TABLE."e;.DatePayment, '%d.%m.%Y') as dPay FROM "e;.OBJECT_X_TABLE."e;$classid,"e;.SHOP_TABLE."e; "e;;
$sqlOo .="e;WHERE "e;.OBJECT_X_TABLE."e;$classid.OF_ID = "e;.SHOP_TABLE."e;.IntArticleID"e;;
$sqlOo .= "e; AND YEAR("e;.SHOP_TABLE."e;.DateOrder) = $optYear ORDER BY "e;.SHOP_TABLE."e;.DateOrder"e;;What if the $fieldnames[3] itself is an array. Lets say, somebody insert a comma-separated list in his form and the mysql-table would look like this:
Code: Select all
|---------------|------------------|---------------------|
| ID | strFilename | strFields |
|---------------|------------------|---------------------|
| 1 | shop_pref | €|16|german|6,7,8,9 |Code: Select all
$fe = explode("e;,"e;,$fieldnameї3]);
foreach($fe as $key => $val)
{
echo $key."e; is "e;.$val."e;<br />\n"e;;
}
echo $feї2];0 is 6
1 is 7
2 is 8
3 is 9
8
So up to here I have the values in my array. But still I need to use any of that figures in my SELECT. How could this be done?