Site icon Hip-Hop Website Design and Development

Retrieve feedback from present put up utilizing SQL

I’m attempting to make use of this code under to auto-refresh feedback however in the meanwhile it’s displaying all feedback. I wish to solely present feedback for the present put up. I’m not very skilled with SQL and do not know learn how to go about doing this:

<?php
operate dp_recent_comments_ajax() {
        $no_comments = 5;
    $comment_len = 300;
        world $wpdb;

    $request = "SELECT * FROM $wpdb->feedback";
    $request .= " JOIN $wpdb->posts ON ID = comment_post_ID";
    $request .= " WHERE comment_approved = '1' AND post_status = 'publish' AND post_password =''";
    $request .= " ORDER BY comment_date DESC LIMIT $no_comments";

    $feedback = $wpdb->get_results($request);
    if ($feedback) {
        foreach ($feedback as $remark) {
            ob_start();
            ?>
                <li>
                    <a mode="font-size:12px "href="<?php echo get_permalink( $comment->comment_post_ID ) . '#comment-' . $comment->comment_ID; ?>"><?php echo dp_get_author($remark); ?> on <?php echo $comment->comment_date; ?> :</a><br />
                    <span class="recent-comment-text" fashion="font-size:11px;font-style:italic"><?php echo strip_tags(substr(apply_filters('get_comment_text', $comment->comment_content), 0, $comment_len)); ?>..</span>
                </li>
            <?php
            ob_end_flush();
        }
    } else {
        echo '<li>'.__('No feedback', 'my-first-wp-theme').'</li>';
    }
    die(); // that is wanted for ajax to work correctly
}
operate dp_get_author($remark) {
    $creator = "";

    if ( empty($comment->comment_author) )
        $creator = __('Nameless', 'my-first-wp-theme');
    else
        $creator = $comment->comment_author;

    return $creator;
}
add_action('wp_ajax_my_recent_comments', 'dp_recent_comments_ajax');
add_action('wp_ajax_nopriv_my_recent_comments', 'dp_recent_comments_ajax'); //for customers that aren't logged in