Template Name: AJAX */ ?> <?php if ($_POST['like_film_id']) { if (!$_SESSION['like']) { $insert = $wpdb->query("UPDATE " . DATA_FILM_META . " \n\t\t\t\t\t\t\t\t\tSET \n\t\t\t\t\t\t\t\t\t\tfilm_like = film_like + 1\n\t\t\t\t\t\t\t\t\t\t, film_rating_total = film_rating_total + 1 \n\t\t\t\t\t\t\t\t\tWHERE film_id = '" . $_POST['like_film_id'] . "'"); if ($insert) { $_SESSION['like'] = $insert->film_like; $like = "Thích phim này thành công"; } } else { $like = "bạn đã đánh giá phim này"; } $liked = get_total_rating($_POST['like_film_id'], 'like'); $member = array('data' => true, 'film' => $liked); //dung ham json_encode de chuyen mang $member thanh chuoi JSON echo json_encode($member); //ket thuc tra ve du lieu va stop khong cho chay tiep die; } elseif ($_POST['film_id']) { if (is_user_logged_in()) { $filmid = $_POST['film_id']; $user_id = get_current_user_id(); $check = $wpdb->get_row("SELECT box_phim FROM wp_boxfilm WHERE box_phim={$filmid} AND box_user={$user_id}"); if (count($check) > 0) { $message = "Bạn đã add phim này rồi"; } else { $wpdb->query("INSERT INTO wp_boxfilm VALUES (0,{$filmid},{$user_id})"); $message = "Add vào hộp phim thành công";
function get_film_home($type, $num = 16, $excerpt_length = 40) { global $post; // tao cache query_posts('post_type=post&showposts=' . $num . '&meta_key=phim_loai&meta_value=' . $type . '&paged=' . $q . '&order=desc'); while (have_posts()) { the_post(); $html .= '<li><div class="inner"><a href="' . get_permalink() . '" title="' . get_the_title() . '"><img src="' . img3(146, 195) . '" alt="' . get_the_title() . '"/></a><div class="info"><div class="name"><h3><a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_title() . '</a></h3> </div><div class="name2"><h4>' . get_post_meta($post->ID, "phim_en", true) . '</h4></div><div class="stats"><span class="liked">' . get_total_rating($post->ID, "like") . ' like</span></div><h5 style="text-indent:-9999px;">' . get_excerpt_content($excerpt_length, '', 0, $post->post_content) . '</h5></div><div class="status"><span class="status_r">' . get_post_meta($post->ID, "phim_tl", true) . '</span></div></div></li> '; } wp_reset_query(); return $html; }
img(146, 195); ?> "></a><div class="info"><div class="name"><h3><a title="<?php the_title(); ?> " href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h3></div><div class="name2"><?php echo get_post_meta($post->ID, "phim_en", true); ?> </div><div class="stats"><span class="liked"><?php echo get_total_rating($post->ID, "like"); ?> like</span></div></div><div class="status"><?php echo get_post_meta($post->ID, "phim_tl", true); ?> </div></div> </li> <?php } echo '</ul>'; wp_reset_query(); } } ?> <div> </div></div>
<div id="content"> <div class="block" id="page-list"> <div class="blocktitle breadcrumbs"> <?php the_breadcrumb(); ?> <?php echo get_cat_name($cat); ?> </div> <div class="blockbody"> <ul class="list-film"> <?php while (have_posts()) { the_post(); $html .= '<li><div class="inner"><a href="' . get_permalink() . '" title="' . get_the_title() . '"><img src="' . img3(146, 195) . '" alt="' . get_the_title() . '"/></a><div class="info"><div class="name"><a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_title() . '</a> </div><div class="name2"><h4>' . get_post_meta($post->ID, "phim_en", true) . '</h4></div><div class="stats"><span class="liked">' . get_total_rating($post->ID, "like") . ' Like</span></div></div><div class="status">' . get_post_meta($post->ID, "phim_hd", true) . '</div></div></li>'; } wp_reset_query(); echo $html; ?> </ul> </div> </div> </div> <?php get_sidebar(); ?> </div> <?php