셀렉트박스 간편하게 만들기 정보
PHP 셀렉트박스 간편하게 만들기본문
<select name="in_its" class="input" itemname="과목선택" required>
<?=select_set2("bo_table" ,"is_id", 1, "--과목선택--")?> <!-- 테이블,조회할 필드, 필드에매치값, 기본값-->
</select>
>>>>>>>>>>>>>>>
// 테이블에 필드값 선택하여 값 가져오기 셀렉트박스
function select_set2($bo_table='', $filed1, $type, $msg="" )
{
global $g4, $board;
$sql = " select is_items from $bo_table where $filed1 = '$type' ";
$row = sql_fetch($sql);
$arr = explode("|", $row[is_items]); // 구분자가 , 로 되어 있음
//$arr = explode("|", $board[bo_category_list]); // 구분자가 , 로 되어 있음
$str = "";
if ($msg)
$str .= "<option value=''>{$msg}</option>\n";
for ($i=0; $i<count($arr); $i++)
if (trim($arr[$i]))
$str .= "<option value='$arr[$i]'>$arr[$i]</option>\n";
return $str;
}
<?=select_set2("bo_table" ,"is_id", 1, "--과목선택--")?> <!-- 테이블,조회할 필드, 필드에매치값, 기본값-->
</select>
>>>>>>>>>>>>>>>
// 테이블에 필드값 선택하여 값 가져오기 셀렉트박스
function select_set2($bo_table='', $filed1, $type, $msg="" )
{
global $g4, $board;
$sql = " select is_items from $bo_table where $filed1 = '$type' ";
$row = sql_fetch($sql);
$arr = explode("|", $row[is_items]); // 구분자가 , 로 되어 있음
//$arr = explode("|", $board[bo_category_list]); // 구분자가 , 로 되어 있음
$str = "";
if ($msg)
$str .= "<option value=''>{$msg}</option>\n";
for ($i=0; $i<count($arr); $i++)
if (trim($arr[$i]))
$str .= "<option value='$arr[$i]'>$arr[$i]</option>\n";
return $str;
}
추천
0
0
댓글 1개
감사합니다