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:
PHP-Code:
	
	
|---------------|------------------|---------------------|
|     ID        |    strFilename   |     strFields       |
|---------------|------------------|---------------------|
|     1         |    shop_pref     |   €|16|german|6     | 
PHP-Code:
	
	
SELECT strFields from ".VIEW_PREFS_TABLE." where strFilename = 'shop_pref'
.... 
PHP-Code:
	
	
$fieldnames = explode("|",$DB_WE->f("strFields"));
$classid= $fieldnames[3]; 
Only for the record:
I need to use that value in another SELECT wich is here:
PHP-Code:
	
	
 $sqlOo = "SELECT ".OBJECT_X_TABLE."$classid.input_shoptitle as obTitle,";
$sqlOo .= ".OBJECT_X_TABLE."$classid.OF_ID as obID,".SHOP_TABLE.".IntArticleID as aID,";
$sqlOo .= ".SHOP_TABLE.".IntOrderID as oID, DATE_FORMAT(".SHOP_TABLE.".DateOrder, '%d.%m.%Y - %H:%m:%s') as procd,";
$sqlOo .= ".SHOP_TABLE.".Price * ".SHOP_TABLE.".IntQuantity as sumt, DATE_FORMAT(".SHOP_TABLE.".DatePayment, '%d.%m.%Y') as dPay";
$sqlOo .= " FROM ".OBJECT_X_TABLE."$classid,".SHOP_TABLE." "; 
   $sqlOo .="WHERE ".OBJECT_X_TABLE."$classid.OF_ID = ".SHOP_TABLE.".IntArticleID";
   $sqlOo .= " AND YEAR(".SHOP_TABLE.".DateOrder) = $optYear ORDER BY ".SHOP_TABLE.".DateOrder"; 
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:
PHP-Code:
	
	
|---------------|------------------|---------------------|
|     ID        |    strFilename   |     strFields       |
|---------------|------------------|---------------------|
|     1         |    shop_pref     | €|16|german|6,7,8,9 | 
PHP-Code:
	
	
$fe = explode(",",$fieldname[3]);
      foreach($fe as $key => $val)
    {
        echo $key." is ".$val."<br />\n";
       
    }
        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?
 
          

Kommentar