Answer the question
In order to leave comments, you need to log in
How to connect two scripts so that a select is displayed from a php array?
There are two separately working scripts. Is it possible to connect them without knowing the general context of the task? It is necessary that the data from the array be displayed as a list in select
It turned out to display the array in field 2 of the script. But it continues to be displayed as an array and not a list
<select name="<?=$arProperties["FIELD_NAME"]?>" id="<?=$arProperties["FIELD_NAME"]?>" size="<?=$arProperties["SIZE1"]?>">
<?
foreach($arProperties["VARIANTS"] as $arVariants):
?>
<option value="<?=$arVariants["VALUE"]?>"<?if ($arVariants["SELECTED"] == "Y") echo " selected";?>><?=$arVariants["NAME"]?>
<?
global $USER;
$arFilter = array("ID" => $USER->GetID());
$arParams["SELECT"] = array("UF_TT_ADRESS");
$arRes = CUser::GetList($by,$desc,$arFilter,$arParams);
if ($res = $arRes->Fetch()) {
?><? print_r($res["UF_TT_ADRESS"])?><?
}
?>
</option>
<?
endforeach;
?>
</select>
<?
global $USER;
$arFilter = array("ID" => $USER->GetID());
$arParams["SELECT"] = array("UF_TT_ADRESS");
$arRes = CUser::GetList($by,$desc,$arFilter,$arParams);
if ($res = $arRes->Fetch()) {
?><pre><? print_r($res["UF_TT_ADRESS"])?></pre><?
}
?>
<select name="<?=$arProperties["FIELD_NAME"]?>" id="<?=$arProperties["FIELD_NAME"]?>" size="<?=$arProperties["SIZE1"]?>">
<?
foreach($arProperties["VARIANTS"] as $arVariants):
?>
<option value="<?=$arVariants["VALUE"]?>"<?if ($arVariants["SELECTED"] == "Y") echo " selected";?>><?=$arVariants["NAME"]?></option>
<?
endforeach;
?>
</select>
Answer the question
In order to leave comments, you need to log in
Here is a working version with the correct output of the list in the select
<?
global $USER;
$arFilter = array("ID" => $USER->GetID());
$arParams["SELECT"] = array("UF_TT_ADRESS");
$arRes = CUser::GetList($by,$desc,$arFilter,$arParams);
$res = $arRes->Fetch();
?>
<select name="<?=$arProperties["FIELD_NAME"]?>" id="<?=$arProperties["FIELD_NAME"]?>" size="<?=$arProperties["SIZE1"]?>">
<?
foreach($res["UF_TT_ADRESS"] as $variant):
?>
<option value="<?=$variant?>"><?=$variant?></option>
<?
endforeach;
?>
</select>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question