День добрый, программисты, помогите переписать код, который создает одну строку и три столбца(HTML), а мне нужно разбить получаемые данные из массива $arResult, на две строки и по 2 столбца, вот код:
PHP/HTML |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
| <?
/***********************************************
table header
************************************************/
?>
<thead>
<tr>
<th><?=GetMessage("FORM_TIMESTAMP")?><br /><?=SortingEx("s_timestamp")?></th>
<?
$colspan = 3;
if (is_array($arResult["arrColumns"]))
{
foreach ($arResult["arrColumns"] as $arrCol)
{
if (!is_array($arParams["arrNOT_SHOW_TABLE"]) || !in_array($arrCol["SID"], $arParams["arrNOT_SHOW_TABLE"]))
{
if (($arrCol["ADDITIONAL"]=="Y" && $arParams["SHOW_ADDITIONAL"]=="Y") || $arrCol["ADDITIONAL"]!="Y")
{
if (++$colspan > 6)
{
$colspan--;
break;
}
?>
<th><?=$arrCol["RESULTS_TABLE_TITLE"]?></th>
<?
} //endif(($arrCol["ADDITIONAL"]=="Y" && $SHOW_ADDITIONAL=="Y") || $arrCol["ADDITIONAL"]!="Y");
} //endif(!is_array($arrNOT_SHOW_TABLE) || !in_array($arrCol["SID"],$arrNOT_SHOW_TABLE));
} //foreach
} //endif(is_array($arrColumns)) ;
?>
</tr>
</thead>
<?
/***********************************************
table body
************************************************/
?>
<?
if(count($arResult["arrResults"]) > 0)
{
?>
<tbody>
<?
$j=0;
foreach ($arResult["arrResults"] as $arRes)
{
$j++;
?>
<tr>
<td><?=$arRes["TSX_0"]?></td>
<?
$cnt = 3;
foreach ($arResult["arrColumns"] as $FIELD_ID => $arrC)
{
if (!is_array($arParams["arrNOT_SHOW_TABLE"]) || !in_array($arrC["SID"], $arParams["arrNOT_SHOW_TABLE"]))
{
if (($arrC["ADDITIONAL"]=="Y" && $arParams["SHOW_ADDITIONAL"]=="Y") || $arrC["ADDITIONAL"]!="Y")
{
if (++$cnt > 6)
break;
?>
<td>
<?
$arrAnswer = $arResult["arrAnswers"][$arRes["ID"]][$FIELD_ID];
if (is_array($arrAnswer))
{
foreach ($arrAnswer as $key => $arrA)
{
?>
<?if (strlen(trim($arrA["USER_TEXT"])) > 0) {?><?=$arrA["USER_TEXT"]?><br /><?}?>
<?if (strlen(trim($arrA["ANSWER_TEXT"])) > 0) {?><span class='form-anstext'><?=$arrA["ANSWER_TEXT"]?></span> <?}?>
<?if (strlen(trim($arrA["ANSWER_VALUE"])) > 0 && $arParams["SHOW_ANSWER_VALUE"]=="Y") {?>(<span class='form-ansvalue'><?=$arrA["ANSWER_VALUE"]?></span>)<?}?>
<br />
<?
if (intval($arrA["USER_FILE_ID"])>0)
{
if ($arrA["USER_FILE_IS_IMAGE"]=="Y")
{
?>
<?=$arrA["USER_FILE_IMAGE_CODE"]?>
<?
}
else
{
?>
<a title="<?=GetMessage("FORM_VIEW_FILE")?>" target="_blank" href="/bitrix/tools/form_show_file.php?rid=<?=$arRes["ID"]?>&hash=<?=$arrA["USER_FILE_HASH"]?>&lang=<?=LANGUAGE_ID?>"><?=$arrA["USER_FILE_NAME"]?></a><br />
(<?=$arrA["USER_FILE_SIZE_TEXT"]?>)<br />
[ <a title="<?=str_replace("#FILE_NAME#", $arrA["USER_FILE_NAME"], GetMessage("FORM_DOWNLOAD_FILE"))?>" href="/bitrix/tools/form_show_file.php?rid=<?=$arRes["ID"]?>&hash=<?=$arrA["USER_FILE_HASH"]?>&lang=<?=LANGUAGE_ID?>&action=download"><?=GetMessage("FORM_DOWNLOAD")?></a> ]
<?
}
}
?>
<?
} //foreach
} // endif (is_array($arrAnswer));
?>
</td>
<?
} //endif (($arrC["ADDITIONAL"]=="Y" && $SHOW_ADDITIONAL=="Y") || $arrC["ADDITIONAL"]!="Y") ;
} // endif (!is_array($arrNOT_SHOW_TABLE) || !in_array($arrC["SID"],$arrNOT_SHOW_TABLE));
} //foreach
?>
</tr>
<?
} //foreach
?>
</tbody>
<?
}
?>
<?
if ($arParams["HIDE_TOTAL"]!="Y")
{
?>
<tfoot>
<tr>
<th colspan="<?=$colspan?>"><?=GetMessage("FORM_TOTAL")?> <?=$arResult["res_counter"]?></th>
</tr>
</tfoot>
<?
} //endif ($HIDE_TOTAL!="Y");
?>
</table> |
|