#66 에따른 코드를 db 접속 횟수를 줄위기 위해 코드 재수정

This commit is contained in:
chicpro
2013-04-12 18:03:08 +09:00
parent f6a45b08fb
commit 3769d130c8
2 changed files with 18 additions and 17 deletions

View File

@ -9,6 +9,15 @@ include_once (G4_ADMIN_PATH.'/admin.head.php');
//sql_query(" update $g4[shop_cart_table] set ct_status = '완료' where ct_status = '배송' ");
// 배송회사리스트 ---------------------------------------------
$delivery_options = '<option value="">선택하세요</option>'.PHP_EOL;
$sql = " select * from {$g4['shop_delivery_table']} order by dl_order ";
$result = sql_query($sql);
for($i=0; $row=sql_fetch_array($result); $i++) {
$delivery_options .= '<option value="'.$row['dl_id'].'">'.$row['dl_company'].'</option>'.PHP_EOL;
}
// 배송회사리스트 end ---------------------------------------------
$where = " where ";
$sql_search = "";
if ($search != "") {
@ -155,7 +164,10 @@ if ($search) // 검색렬일 때만 처음 버튼을 보여줌
<td><?=$hope_date?></td>
<td><input type="text" name="od_invoice_time[<?=$i?>]" value="<?=$invoice_time?>" class="frm_input" size="20" maxlength="19"></td>
<td>
<?=print_delivery_company($i, $row['dl_id'])?>
<label for="dl_id_<?=$i?>">배송업체</label>
<select name="dl_id[<?=$i?>]" id="dl_id_<?=$i?>">
<?=conv_selected_option($delivery_options, $row['dl_id'])?>
</select>
</td>
<td>
<!-- 값이 바뀌었는지 비교하기 위하여 저장 -->

View File

@ -621,24 +621,13 @@ function alert_opener($msg='', $url='')
exit;
}
// 배송회사를 select 로 출력
function print_delivery_company($no, $val)
// option 리스트에 selected 추가
function conv_selected_option($options, $value)
{
global $g4;
if(!$options)
return '';
$delivery_options = '';
$sql = " select * from {$g4['shop_delivery_table']} order by dl_order ";
$result = sql_query($sql);
for($i=0; $row=sql_fetch_array($result); $i++) {
$selected = get_selected($row['dl_id'], $val);
$delivery_options .= '<option value="'.$row['dl_id'].'"'.$selected.'>'.$row['dl_company'].'</option>'.PHP_EOL;
}
$str = '<label for="dl_id_'.$no.'">배송업체</label>'.PHP_EOL;
$str .= '<select name="dl_id['.$no.']" id="dl_id_'.$no.'">'.PHP_EOL;
$str .= '<option value="">선택하세요</option>'.PHP_EOL;
$str .= $delivery_options;
$str .= '</select>';
$str = str_replace('value="'.$value.'"', 'value="'.$value.'" selected="selected"', $options);
return $str;
}