Jump to content

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...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.