0
두 테이블 'p_tuts'와 'h_tuts'가 있습니다. 반환 된 모든 행을 표시하는 메서드를 사용하고 있습니다. 여러 쿼리를 실행하도록 설정하는 방법을 모르지만 한 번에 하나의 쿼리 만 반환 할 수 있습니다. Heres는 ... 여기 PHP MYSQL 다중 테이블 쿼리
public function QueryAll($my_field, $limit) {
$query = mysql_query("SELECT * from $my_field LIMIT $limit");
$rows = array();
while($row = mysql_fetch_array($query)) {
$rows[] = $row;
}
return $rows; }
정말, 그렇게 내가 모두 여러 테이블을 표시하려면이 클래스를 사용할 수 있습니다 적응하고 싶습니다 내 인덱스 파일
<?php $results = $Database->QueryAll('p_tuts', 5); ?>
<?php foreach ($results as $result): ?>
<div class="tutorial">
<div class="tut_header"><h2><a href="view_article_p.php?id=<?php echo $result['id']; ?>" title="<?php echo $result['tut_header']; ?>"><?php echo $result['tut_header']; ?></a></h2></div>
<div class="tut_poster">Posted by: <a href="#" title="Adam"><?php echo $result['tut_poster']; ?></a> on <?php echo $result['tut_date']; ?></div>
<div class="tut_img rounded"><img src="<?php echo "img_uploads/". $result['tut_img']; ?>" width="180" height="151" /></div>
<div class="tut_content"><p><?php $Website->CharLimit($result['tut_content'], 800); ?></p></div>
</div>
<?php endforeach; ?>
내 코드가 아니라 단지보다 .
종류는이 두 테이블 사이의 관계를 모른 채 대답하기 어려운
입력에 감사드립니다. UNION을 (를) 사용하여 정상적으로 작동했습니다. :) – user863739