결과물
코드
<PHP togather.php>
<style>
table{border-collapse: collapse;
text-align: center;
line-height: 1.5;
border-top: 1px solid #ccc;
border-bottom: 1px solid #ccc;
margin: auto;}
th{ width: 150px;
padding: 10px;
font-weight: bold;
vertical-align: top;
color: rgb(255, 77, 46),;
background: rgb(255, 155, 47);
margin: 20px 10px;}
td{ width: 350px;
padding: 10px;
vertical-align: top;}
a{text-decoration:none}
h2 {
color: linear-gradient(to left, rgb(255, 77, 46), rgb(255, 155, 47));
text-align: center; }
</style>
<br>
<h2>X X 중고</h2>
<br>
<?php
$id=$_GET['id'];
echo "<p>안녕하세요 $id 님</p>";
echo "<button><a href='writetextest.php?id=$id'>글작성</a></button><button><a href='reg.php?id=$id'>등록물품목록</a></button><button><a href='count.php?id=$id'>매칭완료목록</a></button>";
?>
<br>
<table><tr>
<th>No</th><th>제목</th><th>작성자</th><th>작성일</th><th>조회수</th><th>거래매칭</th><th><th><a href="log-in.html">로그아웃</a></th>
<?php
$connect=mysqli_connect("localhost","root","000000");
mysqli_select_db($connect,"used");
if(empty($_GET['page'])){$page=1;}
else
{$page=$_GET['page'];}
$line_page=5;
$block_page=3;
$s1="select * from board";
$result=mysqli_query($connect,$s1);
$totrow=mysqli_num_rows($result);
$totpage=ceil($totrow/$line_page);
$totblock=ceil($totpage/$block_page);
$cblock=ceil($page/$block_page);
$frow=($page-1)*$line_page;
$selrec="select * from board order by no desc limit $frow, $line_page";
$info=mysqli_query($connect,$selrec);
while($rowinfo=mysqli_fetch_array($info))
{
echo "<tr>";
echo "<td> $rowinfo[no] </td>";
echo "<td> <a href='detail.php?title=$rowinfo[title]&id=$_GET[id]&count=$rowinfo[count]'> $rowinfo[title] </a></td>";
echo "<td> $rowinfo[id2] </td>";
echo "<td> $rowinfo[regdate] </td>";
echo "<td> $rowinfo[hits] </td>";
if($rowinfo['id2']==$_GET['id'])
{echo "<td> - </td>";}
else
{if ($rowinfo['count'] == 0) {echo "<td> <button><a href='up.php?id=$_GET[id]&no=$rowinfo[no]'>매칭신청</a></button></td>";}
else{echo "<td> <button><a href='down.php?id=$_GET[id]&no=$rowinfo[no]'>매칭신청</a></button></td>";}
}
if ($rowinfo['count'] == 0)
{echo "<td>매칭중</td>";}
else { echo "<td>매칭완료 </td>";}
echo "</tr>";
}
mysqli_close($connect);
?>
</table></body>
<?php
$fpage=(($cblock-1)*$block_page)+1;
$lpage=min($totpage,$cblock*$block_page);
if($cblock>1)
{
$prvblock=($cblock-1)*$block_page;
echo "<a href='togather.php?page=$prvblock&id=$_GET[id]'>◀이전</a>";
}
for($i=$fpage;$i<=$lpage;$i++)
{
if($i==$page) echo "<b id='ab'>[$i]</b>";
else echo "<a href='togather.php?page=$i&id=$_GET[id]'>[$i]</a>";
}
if($cblock<$totblock)
{
$nxtblock=($cblock+1)*$block_page;
echo "<a href='togather.php?page=$nxtblock&id=$_GET[id]'>다음▶</a>";
}
?>
'데이터베이스 관련 > PHP | HTML' 카테고리의 다른 글
프로젝트 1 [회원가입/아이디중복확인/PHP] (0) | 2022.06.23 |
---|---|
프로젝트 1 [회원가입 기능/PHP] (0) | 2022.06.23 |
프로젝트 1 [로그인 기능/PHP] (0) | 2022.06.22 |
프로젝트 1 [회원가입/HTML/CSS] (0) | 2022.06.21 |
프로젝트 1 [로그인 화면/HTML/CSS] (0) | 2022.06.21 |