How I’m trying to make my webpage work is that 8 of some type of items corresponding to rows in my database are loaded on to the page, and then the user can click a “View More” button and 8 more will be loaded (if there are at least that many more), and can click it again and so forth. My PHP function for handling the “View More” by returning the next 8 items is
// make AJAX handler for getting more projects or case studies
add_action( 'wp_ajax_get_next_eight', 'get_next_eight' );
function get_next_eight ( )
{
global $wpdb;
$q = $wpdb->prepare("SELECT id,compname,sumsmall FROM %s ORDER BY postdate DESC LIMIT %d, 8",
$_POST['workType'],
(intval($_POST['numItemsLoaded'])+1));
$nextEightRows = $wpdb->get_results($q);
die(json_encode($nextEightRows));
}
but it keeps returning nothing, so I have a feeling that there is something wrong with my query
"SELECT id,compname,sumsmall FROM %s ORDER BY postdate DESC LIMIT %d, 8"
Any ideas what is wrong?