<?php
$servername = "localhost";
$database = "database ";
$username = "username";
$password = "password ";
$conn = mysqli_connect($servername, $username, $password, $database);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
mysqli_set_charset($conn, "utf8");
?>
<?php
include "db.php";
$startFrom = $_POST['startFrom'];
$sql = "SELECT * FROM youtube JOIN marketdata2 ON channelTitle=coin WHERE youtube.videoId NOT IN (SELECT videoId FROM watchedvideo WHERE userkey = '$userkey') ORDER BY `publishedAt` DESC LIMIT ".$startFrom.", 4";
$res = mysqli_query($conn, $sql);
$articles = array();
while ($row = mysqli_fetch_assoc($res)){$articles[] = $row;}
echo json_encode($articles);
?>
$sql = "SELECT * FROM youtube JOIN marketdata2 ON channelTitle=coin WHERE youtube.videoId NOT IN (SELECT videoId FROM watchedvideo WHERE userkey = '$userkey') ORDER BY `publishedAt` DESC LIMIT ".$startFrom.", 4";