소스쫌 줄여주세요

· 2013-03-24 (일) 11:17:58 · 972 · 2
if ($total_row == 5) {echo "$blank";}
else{
if ($total_row == 4) {echo "$blank$blank";}
else{
if ($total_row == 3) {echo "$blank$blank$blank";}
else{
if ($total_row == 2) {echo "$blank$blank$blank$blank";}
else{
if ($total_row == 1) {echo "$blank$blank$blank$blank$blank";}
}
}
}
}
for($n=1; $n<$total_row; $n++){
if ($total_row == $n*6+5) {echo "$blank";}
else{
if ($total_row == $n*6+4) {echo "$blank$blank";}
else{
if ($total_row == $n*6+3) {echo "$blank$blank$blank";}
else{
if ($total_row == $n*6+2) {echo "$blank$blank$blank$blank";}
else{
if ($total_row == $n*6+1) {echo "$blank$blank$blank$blank$blank";}
}
}
}
}
}
이건 무언가 없는 칸은 매꿔주는건데...
이거 줄여버릴수 잇나요..?

또..
$operator = "LIKE";
$operator2 = ">=";
$operator3 = "<=";


if ($searchname){
if ($searchprice1){
if ($searchprice2){
if ($searchlevel){
$search1 = "%".$searchname."%";
$search2 = "$searchprice1";
$search3 = "$searchprice2";
$search4 = "$searchlevel";
$searchs = "and `$searchtype1` $operator '$search1' and `$searchtype2` $operator2 '$search2' and `$searchtype3` $operator3 '$search3' and `$searchtype4` $operator3 '$search4'";
}
if (!$searchlevel){
$search1 = "%".$searchname."%";
$search2 = "$searchprice1";
$search3 = "$searchprice2";
$searchs = "and `$searchtype1` $operator '$search1' and `$searchtype2` $operator2 '$search2' and `$searchtype3` $operator3 '$search3''";
}
}
if (!$searchprice2){
if ($searchlevel){
$search1 = "%".$searchname."%";
$search2 = "$searchprice1";
$search4 = "$searchlevel";
$searchs = "and `$searchtype1` $operator '$search1' and `$searchtype2` $operator2 '$search2' and `$searchtype4` $operator3 '$search4'";
}
if (!$searchlevel){
$search1 = "%".$searchname."%";
$search2 = "$searchprice1";
$search4 = "$searchlevel";
$searchs = "and `$searchtype1` $operator '$search1' and `$searchtype2` $operator2 '$search2'";
}
}
}
if (!$searchprice1){
if ($searchprice2){
if ($searchlevel){
$search1 = "%".$searchname."%";
$search3 = "$searchprice2";
$search4 = "$searchlevel";
$searchs = "and `$searchtype1` $operator '$search1' and `$searchtype3` $operator3 '$search3' and `$searchtype4` $operator3 '$search4'";
}
if (!$searchlevel){
$search1 = "%".$searchname."%";
$search3 = "$searchprice2";
$searchs = "and `$searchtype1` $operator '$search1' and `$searchtype3` $operator3 '$search3'";
}
}
if (!$searchprice2){
if ($searchlevel){
$search1 = "%".$searchname."%";
$search4 = "$searchlevel";
$searchs = "and `$searchtype1` $operator '$search1' and `$searchtype4` $operator3 '$search4'";
}
if (!$searchlevel){
$search1 = "%".$searchname."%";
$searchs = "and `$searchtype1` $operator '$search1'";
}
}
}
}
if (!$searchname){
if ($searchprice1){
if ($searchprice2){
if ($searchlevel){
$search2 = "$searchprice1";
$search3 = "$searchprice2";
$search4 = "$searchlevel";
$searchs = "and `$searchtype2` $operator2 '$search2' and `$searchtype3` $operator3 '$search3' and `$searchtype4` $operator3 '$search4'";
}
if (!$searchlevel){
$search2 = "$searchprice1";
$search3 = "$searchprice2";
$searchs = "and `$searchtype2` $operator2 '$search2' and `$searchtype3` $operator3 '$search3''";
}
}
if (!$searchprice2){
if ($searchlevel){
$search2 = "$searchprice1";
$search4 = "$searchlevel";
$searchs = "and `$searchtype2` $operator2 '$search2' and `$searchtype4` $operator3 '$search4'";
}
if (!$searchlevel){
$search2 = "$searchprice1";
$searchs = "and `$searchtype2` $operator2 '$search2'";
}
}
}
if (!$searchprice1){
if ($searchprice2){
if ($searchlevel){
$search3 = "$searchprice2";
$search4 = "$searchlevel";
$searchs = "and `$searchtype3` $operator3 '$search3' and `$searchtype4` $operator3 '$search4'";
}
if (!$searchlevel){
$search3 = "$searchprice2";
$searchs = "and `$searchtype3` $operator3 '$search3'";
}
}
if (!$searchprice2){
if ($searchlevel){
$search4 = "$searchlevel";
$searchs = "and `$searchtype4` $operator3 '$search4'";
}
if (!$searchlevel){
$searchs = " ";
}
}
}
}
이거 검색하는건데... 뭔가 if 문이 너무 많이 들어가버려서..
|

댓글 2개

for($i=5; $i>=$total_row; $i--) echo $blank;
for($i=5; $i>=( $total_row % 6 ); $i--) echo $blank;
검색부분은 설명이 없으니 패스..빈 칸 채우기만
if($total_row<6) $len= 6-$total_row;
else $len= 6 - $total_row %6;
if($len) $blank=str_repeat(' ', $len);

echo "그누{$blank}보드";
댓글을 작성하시려면 로그인이 필요합니다.

그누4 질문답변

66,531건

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기 기존 게시물은 열람만 가능합니다.

+
제목 글쓴이 날짜 조회
13-03-25 조회 914
13-03-24 조회 800
13-03-24 조회 1,096
13-03-24 조회 1,703
13-03-24 조회 1,733
13-03-24 조회 1,848
13-03-24 조회 1,998
13-03-24 조회 2,765
13-03-24 조회 792
13-03-24 조회 1,842
13-03-24 조회 1,878
13-03-24 조회 973
13-03-24 조회 1,690
13-03-24 조회 2,023
13-03-24 조회 1,393
13-03-23 조회 1,896
13-03-23 조회 849
13-03-23 조회 1,149
13-03-23 조회 1,858
13-03-23 조회 939