그 최신글을 불러오는데 생긴 문제가있습니다.
<table width="600" border="0" align="center">
<?
$sql = "select * from $board where bo_table='freeboard' ";
$result = mysql_query($sql, $connect);
while($row = mysql_fetch_array($result)){
?>
<tr>
<td><?=$row[name]?>
</td>
</tr>
<?
}
?>
</table>
이렇게해서 나뒀는데
이렇게 이미지를 보시다시피
밑으로만 나옵니다. 밑으로 나오면서 옆으로도 나오게하는방법이 없을까요?
그래서
<?
if($cnt%2==0) echo "<tr><td></td></tr>";
?>
이렇게 했는데.. 잘 모르겠떠라구요.. 밑으로 나오면서 옆으로도 나오게하고싶은데..ㅜ
도와주세요우ㅜ
답변 3개 / 댓글 8개
tr 태그가 저렇게 loop 돌때마다 나오면 당연히 줄바꿈해서 나옵니다
아래처럼
<table width="600" border="0" align="center">
<tr><-----------여기 tr추가
<?
$sql = "select * from $board where bo_table='freeboard' ";
$result = mysql_query($sql, $connect);
$k=0; //---추가
while($row = mysql_fetch_array($result)){
$k++;
if($k % 2 == 1) echo "</tr>tr>"; <--- 조건 3,5,7,9...일때 줄바꿈
?>
<td><?=$row[name]?></td>
<?}?>
</tr> <---추가
</table>
답변에 대한 댓글 1개
<table width="600" border="0" align="center">
<?
$sql = "select * from $board where bo_table='freeboard' ";
$result = mysql_query($sql, $connect);
while($row = mysql_fetch_array($result)){
?>
<tr>
<td>
<div style="width:250px; display:inline-block;"><?=$row['name']?></div>
<div style="width:250px; display:inline-block;"><?=$row['name']?></div>
</td>
</tr>
<?
}
?>
</table>
이런 식으로 바꿔 보세요.
while($row = mysql_fetch_array($result)){
?>
<tr>
<td><?php $row['name']?></td>
<td><?php $row['필드이름2']?></td>
<td><?php $row['필드이름3']?></td>
<td><?php $row['필드이름4']?></td>
</tr>
<?php
}
?>
답변에 대한 댓글 7개
테이블 하나 더 병렬로 나오게 하시려는 건가요?
그렇지 않다면 다음과 같이 위의 소스를 한 번 더 실행해야 할 겁니다.
[code]
<!-- freeboard 의 최신글 -->
<table width="300" border="0" align="left">
<?php
$sql = "select * from $board where bo_table='freeboard' ";
$result = mysql_query($sql, $connect);
while($row = mysql_fetch_array($result)){
?>
<tr><td><?=$row[name]?></td></tr>
<?php } ?>
</table>
<!-- noticeboard 의 최신글 -->
<table width="300" border="0" align="right">
<?php
$sql = "select * from $board where bo_table='noticeboard' ";
$result = mysql_query($sql, $connect);
while($row = mysql_fetch_array($result)){
?>
<tr><td><?=$row[name]?></td></tr>
<?php } ?>
</table>
[/code]
만약 그렇다면 width 값을 좀더 줄여 보시고,
그래도 안되면
<table border="0" style="display:inline-block; width:300px; text-align:left;">
이런 식으로 테이블에 스타일을 적용해 보세요.
내용물
내용물
내용물
내용물
이렇게나오고
제가 원하는것은
내용물 내용물
내용물 내용물
내용물 내용물
내용물 내용물
이런식으로 나오게하는거라구요
답변을 작성하려면 로그인이 필요합니다.