반복테이블을 2행으로 보이게 하려면 소스를 어떻게 바꿔야 할까요?

· 2010-08-16 (월) 15:59:28 · 1673 · 6
<?
unset($searchWhere);

$where_ = " code !='".nowSaleItem('01')."' and ";
$where_ .= " code !='".nowSaleItem('02')."' and ";
$where_ .= " code !='".nowSaleItem('03')."' and ";
$where_ .= " code !='".nowSaleItem('04')."' and ";
$where_ .= " code !='".nowSaleItem('05')."' and ";


if($oldSearchWord) $searchWhere[] = " name like '%".$oldSearchWord."%' and ";

if($viewCategory) $searchWhere[] = " cateCode = '".$cateDefineArray2[$viewCategory]."' and ";

$que = "select * from snsProduct where ".$where_." ".@implode("",$searchWhere)." sale_date < '".date('Y-m-d')."' and seeDisabled != '1' and code = parent_code and sale_date like '".$thisMonth."%' order by sale_date desc";

$res = mysql_query($que);

if(!mysql_num_rows($res)) {
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height=30 align=center>검색 결과가 없습니다.</td>
</tr>
</table>

<?
}


while($row = mysql_fetch_array($res)) {
$row[name] = $oldSearchWord ? str_replace($oldSearchWord,"<span style='color:blue;background:yellow'>".$oldSearchWord."</span>",$row[name]) : $row[name];
?>

<!-- 루프 -->

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><?=date('Y. m. d',strtotime($row[sale_date])) ?><?=$row[name]=></td>
</tr>
</table>

</td>
</tr>
</table>

<?
}
?>
<!-- 루프 끝 -->


위의 소스를 ftp에 넣고 확인을 해보면
날짜이름
날짜이름
날짜이름
.
.
.
이런식으로 1행으로 출력이 됩니다.
이것을 2행으로 출력이 되게 고치려면 어떻게 해야할까요?

날짜이름 날짜이름
날짜이름 날짜이름
날짜이름 날짜이름
.
.

이런식으로 보이게 하고싶은데 ㅜ.ㅜ
아무리 해봐도 제대로 안보이네요 ;;
조언을 부탁드립니다 ^ ^
|

댓글 6개

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
if(!mysql_num_rows($res)) {
?>

<td height=30 align=center>검색 결과가 없습니다.</td>


<?
} else {


for($i = 0 ; $row = mysql_fetch_array($res); $i++ ) {
$row[name] = $oldSearchWord ? str_replace($oldSearchWord,"<span style='color:blue;background:yellow'>".$oldSearchWord."</span>",$row[name]) : $row[name];
?>
<? if($i !=0 && $i/2 == 0) { ?>
</tr><tr>
<? } ?>
<!-- 루프 -->


<td>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><?=date('Y. m. d',strtotime($row[sale_date])) ?><?=$row[name]=></td>
</tr>
</table>

</td>

<?
} }
?>

</tr>
</table>

<!-- 루프 끝 -->
2010-08-16 (월) 16:58:35
타이핑님 감사합니다 : )
적용을 해보았는데
날짜이름
날짜이름
날짜이름
.
.
이런식으로 출력되던것이 알려주신 소스를 적용하면
날짜이름 날짜이름 날짜이름 . . . . 이런식으로 가로로 배열이 되네요 ㅜ.ㅜ
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<? for($i = 0; $row = mysql_fetch_array($res); $i++) { ?>
<td><?=date('Y. m. d',strtotime($row[sale_date])) ?><?=$row[name]?></td>
<? if (($i + 1) % 2 == 0) echo "</tr><tr>"; ?>
<? } ?>
</tr>
</table>
2010-08-16 (월) 17:55:14
OH플 님 감사합니다 : )
바로 적용을 해보았습니다.
근데 원래 현재까지 등록되어있던 검색값 4개가 나와야하는데
총 3개가 검색이 되요
이건 왜이럴까요?
$row = mysql_fetch_array($res)가 중복됐나 확인해보세요.
2010-08-16 (월) 18:03:19
너무 감사합니다 해결되었습니다 ^^
댓글을 작성하시려면 로그인이 필요합니다.

그누4 질문답변

66,531건

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

+
제목 글쓴이 날짜 조회
10-08-16 조회 2,316
10-08-16 조회 1,674
10-08-16 조회 1,713
10-08-16 조회 1,738
10-08-16 조회 1,624
10-08-16 조회 1,864
10-08-16 조회 1,622
10-08-16 조회 1,730
10-08-16 조회 1,632
10-08-16 조회 1,621
10-08-15 조회 2,119
10-08-15 조회 1,322
10-08-15 조회 1,865
10-08-15 조회 1,849
10-08-15 조회 1,803
10-08-15 조회 1,705
10-08-15 조회 1,666
10-08-15 조회 2,001
10-08-14 조회 1,754
10-08-14 조회 4,948