A
A
Abay Tazhigaliev2016-02-12 08:13:37
PHP
Abay Tazhigaliev, 2016-02-12 08:13:37

How to display link to previous and next video by title_url, can't make if condition and path?

294a288aead14103b960c0c6196c8b07.jpg
/// Function to get video information, full video page
function get_data($table,$title,$lang){
db_connect();
$query = sprintf("SELECT * FROM $table WHERE $table.title_url = '%s' AND $table.lang = '%s' ",
mysql_real_escape_string($title),
mysql_real_escape_string($lang));
$result = mysql_query($query);
$row = mysql_fetch_array($result);
return $row;
}
///Function for Prev and Next Video
function select_one_video($title, $lang){
db_connect();
$query = "SELECT `video`.*, (SELECT count(c.`id`) FROM `comments` c WHERE c.`note_id` = `video`.`title_url` AND c.`lang` = '{$ lang}') comments_count
FROM `video`
WHERE `video` .`id` > (SELECT v.`id` FROM `video` v WHERE v.`id` < {$title} ORDER BY v.`id` DESC LIMIT 1) AND `video`.`lang` = '{$lang}'
ORDER BY `video` .`id` ASC
LIMIT 3";
$result = mysql_query($query);
$result = db_result_to_array($result);
return $result;
}
This is the video.php file.
You need to write the condition if
<?php
$title = $_GET['t'];
if(!empty($title)){
$sel_one_video = select_one_video($title, $lang);
}
?>

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
look2009, 2016-02-12
@look2009

Here it is better to arrange the video in a table with an additional field like sid (int 11) 1,2,3,4,5,6,7,8,9 ... and in the get assign sid-1 and sid+1 when outputting, ask to display by default 1, and then when you click next, filter if more than 1 then the request, this can be put into 1 function. This greatly simplifies the implementation and speed of work.
Table structure
| id | title | language | url | catid (if there are categories) | sid (sort by category in order) | ....
You have a strange implementation. It is not clear why the tables to jump.

N
Nicholas, 2016-02-12
@ACCNCC

You to the freelance exchange!

A
Abay Tazhigaliev, 2016-02-12
@webcoderpro

There are other tables, article and photo

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question