Initial
This commit is contained in:
23
Crocoblock/JetReviews/get_jet_reviews_from_db/index.php
Normal file
23
Crocoblock/JetReviews/get_jet_reviews_from_db/index.php
Normal file
@ -0,0 +1,23 @@
|
||||
<? php
|
||||
|
||||
function get_jet_reviews() {
|
||||
global $wpdb;
|
||||
|
||||
// Query the first 10 rows from the wp_jet_reviews table
|
||||
$results = $wpdb->get_results(
|
||||
"SELECT * FROM {$wpdb->prefix}jet_reviews LIMIT 10",
|
||||
ARRAY_A
|
||||
);
|
||||
|
||||
// Check if there are any results
|
||||
if ( ! empty( $results ) ) {
|
||||
// Return the results as JSON
|
||||
return wp_json_encode( $results );
|
||||
} else {
|
||||
// If no results are found, return an empty array as JSON
|
||||
return wp_json_encode( array() );
|
||||
}
|
||||
}
|
||||
|
||||
// Example: Use the function and print the result
|
||||
echo get_jet_reviews();
|
||||
Reference in New Issue
Block a user