change function to work with worpress
-
Hello, I was wondering how to convert this function to work with wordpress? I’ve taken a look at developer.ww.wp.xz.cn/reference/classes/wpdb/prepare but I’m confused. It doesn’t mention bind_param.
function build_calendar($month, $year) { $mysqli = new mysqli('localhost', 'root', '', 'bookingcalendar'); $stmt = $mysqli->prepare("select * from bookings where MONTH(date) = ? AND YEAR(date)=?"); $stmt->bind_param('ss', $month, $year); $bookings = array(); if($stmt->execute()){ $result = $stmt->get_result(); if($result->num_rows>0){ while($row = $result->fetch_assoc()){ $bookings[] = $row['date']; } $stmt->close(); }Here’s the code that came up with but can anyone help to fix it?
global $wpdb; $table_name = $wpdb->prefix . "bookings"; $stmt = $wpdb->prepare( "SELECT * FROM $table_name WHERE MONTH(date) = ? AND YEAR(date)=?"); $results = $wpdb->get_results( $stmt );The page I need help with: [log in to see the link]
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘change function to work with worpress’ is closed to new replies.