2010-01-04 4 views
1

아래에 설명 된 것처럼 "info"라는 MySQL 테이블이 있고 아래에 설명 된대로 HTML 테이블을 인쇄하고 싶다면 어떻게해야합니까?테이블에 쿼리 결과 인쇄

필드 MySQL의 테이블 :

id subject category actions date status 

HTML 테이블 구조 : 두 개의 열, 첫 번째 필드가 포함 다음 "작업을"내림차순 "행동"으로 분류 필드 "주제"를 포함. 경우에만 다음가는 "카테고리는"사용자가 변수 "$ 찾기"내가 시작할 것이라고 곳

다음

그대로 입력 한 내용과 일치하는 경우 항목을 보여,하지만 난 모르겠어요 :

$result=mysql_query("SELECT subject, actions FROM info WHERE category='$find' ORDER BY votes DESC") 
or die(mysql_error()); 

if(mysql_num_rows($result)>0){ 
while($table=mysql_fetch_row($result)){ 

감사에서 사전,

존이 같이

+2

미안 해요,하지만이 숙제 같은 냄새가 난다. –

+0

html로 테이블을 만드는 법을 알고 있습니까? – user242294

+0

하우 쉬우가가 번 – John

답변

0

:

<?php 
$result = mysql_query("SELECT subject, actions FROM info WHERE category='$find' ORDER BY votes DESC") or die(mysql_error()); 

if(mysql_num_rows($result) > 0): ?> 
<table> 
    <tr> 
     <th>Subject</th> 
     <th>Actions</th> 
    <tr> 
    <?php while($row = mysql_fetch_assoc($result)): ?> 
    <tr> 
     <td><?php echo $row['subject']; ?></td> 
     <td><?php echo $row['actions']; ?></td> 
    </tr> 
    <?php endwhile; ?> 
</table> 
<?php endif; ?> 
+0

감사합니다 ... $ 탭은 어디에서 왔습니까? 대신 $를 찾아야합니까? – John

+0

$ tab은 $ row가되어야한다고 생각합니다. – John

+0

@ John, yea, fixed –