When you're satisfied you mark your own threads resolved under "thread tools" above the first post.
There is one thing you could improve, and that is replacing the queries in the while loops with one query, containing a subquery. Not tested, but it should look something like this
$query = "SELECT vcom.*, vcat.*, t.*
FROM (SELECT * FROM $tbl_name ORDER BY published_date DESC LIMIT $start, $limit) AS t
LEFT JOIN vidcomments vcom ON vcom.vid = t.vid
INNER JOIN vcategories vcat ON vcat.vcid = t.vcid"
# Do note that this query will pull several fields sharing the same name. Only one of
# them will end up in the result set unless you alias them: vcom.vid AS vcom_vid
# But it is not necessary to do this unless you have fields with different values sharing
# the same name. vid and vcid do exist in more than one table, but they are also used
# to join tables together, so they should be the same from both involved tables anyway.
The nested query is needed to have the limit clause limit the number of videos retrieved, rather than vidcomments. To make this work, you would have to restructure your code to handle output, or make life easier by first setting up an array like this
$vids = array();
foreach ($row as mysql_fetch_assoc($result)) {
# create an array where each element consists of an array of comments
# for that video, and also include data from the video and category tables
$vids[$row['vid']][] = $row;
}
# The rest of the code pretty much as before, except you replace your
# while(mysql_fetch_assoc()) loops with foreach loops
foreach ($vids as $vid) {
# echo the same things you did for the video previously
echo ...;
foreach ($vid as $comments) {
# echo the same things you for the comments previously
}
# echo the same things you did for the category previously
echo ...;
}
This way, you'd only issue one query, which does contain a subquery, but you still reduce the number of queries which is good from an efficiency perspective.