묻고답하기
page_full_width" class="col-xs-12" |cond="$__Context->page_full_width">
이상하게 만들긴 했는데,, 완벽하게 고쳐주실분?
2003.01.17 22:52
우여곡절 끝에 카테고리 자동 등록하게 했는데,,
나중에 많이 쓰다보면 문제점이 생길 수 있는 부분 찾아주세용~
참고로, 맨밑에 mysql 닫는건 일부러 안넣었구용...
update 하는 부분 ..... 저게 조금 거슬리네여;;
$connect=mysql_connect($host_name,$user_name,$db_password);
mysql_select_db($db_name);
$result=mysql_query("select * from zetyx_board_$id2 order by no desc limit $number");
while($data=mysql_fetch_array($result))
{
$data[subject] = stripslashes($data[subject]);
$data[no] = stripslashes($data[no]);
$count = strlen($data[subject]);
if($count >= $max) {
for ($pos=$max;$pos>0 && ord($new[subject][$pos-1])>=127;$pos--);
if (($max-$pos)%2 == 0)
$data[subject] = substr($data[subject], 0, $max);
else
$data[subject] = substr($data[subject], 0, $max+1);
}
else {
$data[subject] = "$data[subject]";
}
switch($data[subject]) {
case A : $total=1; break;
case a : $total=1; break;
case B : $total=2; break;
case b : $total=2; break;
case C : $total=3; break;
case c : $total=3; break;
case D : $total=4; break;
case d : $total=4; break;
case E : $total=5; break;
case e : $total=5; break;
case F : $total=6; break;
case f : $total=6; break;
case G : $total=7; break;
case g : $total=7; break;
case H : $total=8; break;
case h : $total=8; break;
case I : $total=9; break;
case i : $total=9; break;
case J : $total=10; break;
case j : $total=10; break;
case K : $total=11; break;
case k : $total=11; break;
case L : $total=12; break;
case l : $total=12; break;
case M : $total=13; break;
case m : $total=13; break;
case N : $total=14; break;
case n : $total=14; break;
case O : $total=15; break;
case o : $total=15; break;
case P : $total=16; break;
case p : $total=16; break;
case Q : $total=17; break;
case q : $total=17; break;
case R : $total=18; break;
case r : $total=18; break;
case S : $total=19; break;
case s : $total=19; break;
case T : $total=20; break;
case t : $total=20; break;
case U : $total=21; break;
case u : $total=21; break;
case V : $total=22; break;
case v : $total=22; break;
case W : $total=23; break;
case w : $total=23; break;
case X : $total=24; break;
case x : $total=24; break;
case Y : $total=25; break;
case y : $total=25; break;
case Z : $total=26; break;
case z : $total=26; break;
default : $total=27;
}
mysql_query("update zetyx_board_$id2 set category='$total' where no='$data[no]'");
mysql_query("update $t_category"."_$id2 set num=num+1 where no='$total'");
}
나중에 많이 쓰다보면 문제점이 생길 수 있는 부분 찾아주세용~
참고로, 맨밑에 mysql 닫는건 일부러 안넣었구용...
update 하는 부분 ..... 저게 조금 거슬리네여;;
$connect=mysql_connect($host_name,$user_name,$db_password);
mysql_select_db($db_name);
$result=mysql_query("select * from zetyx_board_$id2 order by no desc limit $number");
while($data=mysql_fetch_array($result))
{
$data[subject] = stripslashes($data[subject]);
$data[no] = stripslashes($data[no]);
$count = strlen($data[subject]);
if($count >= $max) {
for ($pos=$max;$pos>0 && ord($new[subject][$pos-1])>=127;$pos--);
if (($max-$pos)%2 == 0)
$data[subject] = substr($data[subject], 0, $max);
else
$data[subject] = substr($data[subject], 0, $max+1);
}
else {
$data[subject] = "$data[subject]";
}
switch($data[subject]) {
case A : $total=1; break;
case a : $total=1; break;
case B : $total=2; break;
case b : $total=2; break;
case C : $total=3; break;
case c : $total=3; break;
case D : $total=4; break;
case d : $total=4; break;
case E : $total=5; break;
case e : $total=5; break;
case F : $total=6; break;
case f : $total=6; break;
case G : $total=7; break;
case g : $total=7; break;
case H : $total=8; break;
case h : $total=8; break;
case I : $total=9; break;
case i : $total=9; break;
case J : $total=10; break;
case j : $total=10; break;
case K : $total=11; break;
case k : $total=11; break;
case L : $total=12; break;
case l : $total=12; break;
case M : $total=13; break;
case m : $total=13; break;
case N : $total=14; break;
case n : $total=14; break;
case O : $total=15; break;
case o : $total=15; break;
case P : $total=16; break;
case p : $total=16; break;
case Q : $total=17; break;
case q : $total=17; break;
case R : $total=18; break;
case r : $total=18; break;
case S : $total=19; break;
case s : $total=19; break;
case T : $total=20; break;
case t : $total=20; break;
case U : $total=21; break;
case u : $total=21; break;
case V : $total=22; break;
case v : $total=22; break;
case W : $total=23; break;
case w : $total=23; break;
case X : $total=24; break;
case x : $total=24; break;
case Y : $total=25; break;
case y : $total=25; break;
case Z : $total=26; break;
case z : $total=26; break;
default : $total=27;
}
mysql_query("update zetyx_board_$id2 set category='$total' where no='$data[no]'");
mysql_query("update $t_category"."_$id2 set num=num+1 where no='$total'");
}
댓글 5
-
뒹굴리스트
2003.01.17 23:33
주석이 없군요-_;;;; -
Brown
2003.01.17 23:54
-_-;; mysql_query("update zetyx_board_$id2 set category='$total' where no='$data[no]'");
mysql_query("update $t_category"."_$id2 set num=num+1 where no='$total'");
여기 부분이 부족한거 같은데요;; +1 해줬으면 지울때 -1를 해줘야 되는데 어떻게 고치는지;; -
이호한
2003.01.18 01:54
switch문도 좀 고치는게 좋을 것 같습니다.
if( ord($data[subject])>=65 && ord($data[subject])<=90 ) {
$total = ord($data[subject]) - 64;
} elseif( ord($data[subject])>=97 && ord($data[subject])<=122 ) {
$total = ord($data[subject]) - 96
} else {
$total = 27;
} -
행복한고니
2003.01.18 07:06
저 같으면 switch 문을 이렇게... -_-;;
$low_ch = strlower($data[subject]);
$total = ($low_ch >= 'a' && $low_ch <= 'z')?ord($low_ch)-96:27; -
Brown
2003.01.18 15:50
감사합니다^^ 덕분에.. 카테고리 완벽하게 완성 됬어염 ^^.. 그리고 이외 도와주신분들께 감사드립니다~