2012-11-08 3 views
2

두 개의 테이블 imagevideo이 있습니다. 이미지와 비디오의 모든 데이터를 하나의 테이블에 표시하려고합니다. 비디오에서 모든 데이터를 표시하는 방법을 알고 있지만 동일한 테이블에서도 이미지의 모든 데이터를 표시하는 방법을 알고 있습니다. 비디오에서 모든 데이터를 표시하는 테이블이 있지만 비디오의 데이터를 표시 할 때 동일한 테이블의 이미지에서 모든 데이터를 표시하는 방법을 알려줄 수 있습니까?두 테이블의 데이터를 하나의 테이블에 표시하는 방법

<table width="879" border="2" cellpadding="3" cellspacing="1"> 
    <tr> 
    <td colspan="11" align="center" ><strong>All uploaded videos</strong> 
    </td> 
    </tr> 
    <tr> 
    <td width="51" align="center" bgcolor="#000000" class="yellow"><strong>Id</strong></td> 
    <td width="95" align="center" bgcolor="#000000" class="yellow"><strong>Video</strong></td> 
    <td width="83" align="center" bgcolor="#000000" class="yellow"><strong>Name</strong></td> 
    <td width="130" align="center" bgcolor="#000000" class="yellow"><strong>Date</strong></td> 
    <td width="177" align="center" bgcolor="#000000" class="yellow"><strong>Description</strong></td> 
    <td width="101" align="center" bgcolor="#000000" class="yellow"><strong>Price</strong></td> 
    <td width="174" align="center" bgcolor="#000000" class="yellow"><strong>Added by</strong></td> 
    </tr> 

    <?php $path= "videoFile/"; 
    while($rows=mysql_fetch_array($result1)){ 
    ?> 

    <tr> 
    <td> 
     <?php if (current_user_can('manage_options')) { echo $rows['vid'];}else { echo "For admins only!"; } ?> 
    </td> 
    <td><a href="<?php echo $path.$rows['filename'] ?>">View video</a></td> 
    <td><?php echo $rows['alttext']; ?></td> 
    <td><?php echo $rows['imagedate']; ?></td> 
    <td><?php echo $rows['description']; ?></td> 
    <td><?php echo "$".$rows['price']; ?></td> 
    <td><?php echo $rows['user_nicename']; ?></td>  
    </tr> 

    <?php 
    } 
    ?>  
</table> 
+0

귀하의 mysql 쿼리를 보여주십시오. –

+0

$ sql1 = "SELECT * FROM 비디오 가입 wip_users on video.userID = wp_users.id imagedate로 주문"; $ sql2 = "SELECT * FROM 이미지는 images.userID = wp_users.id에서 wp_users에 가입합니다. imagedate로 주문하십시오."; –

답변

0
합격 한 대답 here에 대한
SELECT * 
FROM video 
JOIN wp_users ON wp_users.id = video.userID 
JOIN images ON images.userID = wp_users.id 
ORDER BY imagedate 

확인합니다.

관련 문제