내 웹 사이트의 포럼 페이지는 PHP를 사용하여 테이블을 만든 다음 while 루프를 사용하여 데이터베이스에서 채 웁니다. 이 잘 작동하고 항상 있지만 테이블의 게시물의 전체 첫 번째 섹션에서 게시물의 제목 주위에 태그를 '링크', 앵커 이동하려고했습니다. 다음 단계를 통해가는 이렇게하려면 다음을 수행php while 루프에있는 내용을 벗어난 루프 에코 요소
- 열기 테이블 태그 [LOOP 외부]
- 에코 헤더 [LOOP 외부]
- 시작 모든 게시물에 대한 또 다른 post 섹션을 만드는 루프가 발견하면서 .
- [REPEAT 포스트 날짜 섹션
- 닫기 테이블 행
- 가까운 테이블에 대해 5-7 번 단계를
- 닫기 테이블 데이터 테이블 데이터를 oustide입니다을
- 에코 콘텐츠를 만들 테이블 행
- 만들기 루프의]
첫 번째 섹션 모두에서 링크를 클릭 할 수있게해야합니다.
사람이 설명해 주 시겠어요 : 실제로 그들이이 스크린 샷에서 볼 수 있듯이 테이블의 외부 결국,
<table> <--- *THIS IS BEFORE THE LOOP, IT GETS RUN ONCE ONLY* -->
<WHILE *do this like 5 times or something*>
<tr>
<a *category link*>
<td>
*content for the 'td' which is taken from the DB*
</td>
<td>
*content for the 'td' which is taken from the DB*
</td>
</a>
</tr>
<ENDWHILE>
</table>
그러나이 같은 테이블에서 d를 그것을 고치는 방법?
echo '<table class="forumTable">
<tr>
<th>Category</th>
<th>Last topic</th>
</tr>';
while($row = mysqli_fetch_assoc($catResult)){
echo '<tr>';
echo '<a href="category.php?id=' . htmlspecialchars($row['catID']) . '"><td class="catDesc">';
echo '<h3>' . $row['catName'] . '</h3>' . $row['catDesc'];
echo '</td>';
echo '<td class="catTime">';
$getTops = "SELECT topicID, topicSubject, topicDate, topicCat FROM topics WHERE topicCat = " . $row['catID'] . " ORDER BY topicDate DESC LIMIT 1";
$topResult = mysqli_query($connect, $getTops);
if(!$topResult){
echo '<p style="margin-top: 75px;">The last topic could not be displayed, please try again later.</p>';
}
else{
if(mysqli_num_rows($topResult) == 0){
echo '<p>No topics</p>';
}
else{
while($topRow = mysqli_fetch_assoc($topResult)){
echo '<a href="topic.php?id=' . $topRow['topicID'] . '">' . $topRow['topicSubject'] . '</a> at ' . $topRow['topicDate'];
}
}
}
echo '</td></a>';
echo '</tr>';
}
echo '</table>';
실제 코드를 표시해야합니다.'하지 말아야합니다. –
AbraCadaver
질문에 대한 답변을 얻을 수있는 몇 가지 코드를 보여주십시오. –
아, 죄송합니다. 잊어 버렸습니다. 게시물을 편집했습니다. – iixCarbonxZz