Jump to content

Data from Multiple Table Help Please


ozone1

Recommended Posts

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

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/169751-data-from-multiple-table-help-please/
Share on other sites

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.