include 'bot.php';
$servername = "localhost";
$username = "your_username";
$password = "your_password";
$dbname = "your_database";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Bog'lanishda xatolik yuz berdi: " . $conn->connect_error);
}
switch ($txt) {
case 'Tasodifiy videolar':
// Tasodifiy 10 ta video
$sql = "SELECT * FROM videos ORDER BY RAND() LIMIT 10";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
$i = 1;
$key = [];
while ($row = $result->fetch_assoc()) {
$video_id = $row['video_id'];
$key[] = ["text" => $i, "callback_data" => $video_id];
$i++;
}
$key = array_chunk($key, 5);
$key[] = [
['text' => '⬅️', 'callback_data' => 'previous'],
['text' => '❌️', 'callback_data' => 'close'],
['text' => '➡️', 'callback_data' => 'next']
];
$sql = "SELECT * FROM videos ORDER BY RAND() LIMIT 1";
$f = $conn->query($sql);
$result = $f->fetch_assoc();
$video = $result['video_url'];
$caption = $result['video_caption'];
$reply_markup = json_encode([
'inline_keyboard' => $key,
]);
$bot->sendVideo($cid, $video, $caption, $reply_markup);
}
break;
}
?>
Kimgadur kerak bo'lib qolar :)
$servername = "localhost";
$username = "your_username";
$password = "your_password";
$dbname = "your_database";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Bog'lanishda xatolik yuz berdi: " . $conn->connect_error);
}
switch ($txt) {
case 'Tasodifiy videolar':
// Tasodifiy 10 ta video
$sql = "SELECT * FROM videos ORDER BY RAND() LIMIT 10";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
$i = 1;
$key = [];
while ($row = $result->fetch_assoc()) {
$video_id = $row['video_id'];
$key[] = ["text" => $i, "callback_data" => $video_id];
$i++;
}
$key = array_chunk($key, 5);
$key[] = [
['text' => '⬅️', 'callback_data' => 'previous'],
['text' => '❌️', 'callback_data' => 'close'],
['text' => '➡️', 'callback_data' => 'next']
];
$sql = "SELECT * FROM videos ORDER BY RAND() LIMIT 1";
$f = $conn->query($sql);
$result = $f->fetch_assoc();
$video = $result['video_url'];
$caption = $result['video_caption'];
$reply_markup = json_encode([
'inline_keyboard' => $key,
]);
$bot->sendVideo($cid, $video, $caption, $reply_markup);
}
break;
}
?>
Kimgadur kerak bo'lib qolar :)