<?php 
function add_list($item_id,$user_id){
    $CurrentDate =date("Y-m-d H:i:s"); //currentDate
    $ip=$_SERVER['REMOTE_ADDR'];
    //
    $sql4="SELECT j_user_id from j_courses WHERE j_id='".$item_id."'"; //check 
    $result4 = runSQL($sql4);
    $data =mysqli_fetch_array($result4);
    $owner_id = $data['j_user_id'];
    //insert 
    $sql = "INSERT INTO j_items_listed 
    (j_item_id,j_owner_id,j_user_id,j_ip,j_date)
    VALUES
    ('".$item_id."','".$owner_id."','".$user_id."','".$ip."','".$CurrentDate."')
    ";
    $result = runSQL($sql);
    if($result){ return 1; }else{ return 0; }  
}
function add_view($item_id,$user_id){
    $CurrentDate =date("Y-m-d H:i:s"); //currentDate
    $ip=$_SERVER['REMOTE_ADDR'];
    //
    $sql4="SELECT j_user_id from j_courses WHERE j_id='".$item_id."'"; //check 
    $result4 = runSQL($sql4);
    $data =mysqli_fetch_array($result4);
    $owner_id = $data['j_user_id'];
    //insert 
    $sql = "INSERT INTO j_items_view 
    (j_item_id,j_owner_id,j_user_id,j_ip,j_date)
    VALUES
    ('".$item_id."','".$owner_id."','".$user_id."','".$ip."','".$CurrentDate."')
    ";
    $result = runSQL($sql);
    if($result){ return 1; }else{ return 0; }   
}



function add_lesson_view($item_id,$user_id,$course_id){
    $CurrentDate =date("Y-m-d H:i:s"); //currentDate
    $ip=$_SERVER['REMOTE_ADDR'];
    //
    $sql4="SELECT j_user_id from j_courses_lessons WHERE j_id='".$item_id."'"; //check 
    $result4 = runSQL($sql4);
    $data =mysqli_fetch_array($result4);
    $owner_id = $data['j_user_id'];
    //insert 
    $sql = "INSERT INTO j_items_view 
    (j_lesson_id, j_item_id,j_owner_id,j_user_id,j_ip,j_date)
    VALUES
    ('".$item_id."','".$course_id."','".$owner_id."','".$user_id."','".$ip."','".$CurrentDate."')
    ";
    $result = runSQL($sql);
    if($result){ return 1; }else{ return 0; }   
}


?>