ozone1 Posted August 11, 2009 Share Posted August 11, 2009 Hello guys i need some help to show some data from multiple tables. I have two tables videos and vids in videos i have id category view title in vids i have id video_id views title code ok what i want is to show most viewed videos (from vids table) of current day on my index page from a particular category (on videos table) i made a code and its shows videos from all categories i just want videos from category 14 <?php $result[0] = mysql_query("SELECT vids. * FROM vids, videos WHERE videos.category='14' ORDER BY id DESC LIMIT 10"); for($i=0;$i<count($result);$i++) { echo '<td style="width:190px;font-size:12px;text-align:left;" valign="top">'; while($row=mysql_fetch_array($result[$i])) { $id = $row['id']; $cat = $row['cat']; $title = $row['title']; $numviews = $row['views']; $max_length = 30; $title = ( strlen($title) > $max_length ? substr($title,0,$max_length)."..." : $title ); echo '<li><a href="videos.php?id=' . $id . '" class="forceRight">'. $title . '<a class="numbers">' . $numviews . ' views</a></a></li>'; } } ?> and right now there are 0 views for all videos but still its appearing according to id on my index page i want it to show empty space if the view count is zero Any help much appreciated !!! Thanks Quote Link to comment https://forums.phpfreaks.com/topic/169751-data-from-multiple-table-help-please/ Share on other sites More sharing options...
fenway Posted August 21, 2009 Share Posted August 21, 2009 Whoa... where's the JOIN condition? And don't you want a COUNT()? Quote Link to comment https://forums.phpfreaks.com/topic/169751-data-from-multiple-table-help-please/#findComment-903172 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.