can someone help me convert this to wordpress friendly code.
basically, im creating a custom page where i want to dispaly json_encode
arrays. based on the member ID input.
so if i append id=3
on my custom wordpress page. i want to display the associated name for that id.
when i run below code and type this on my browser http://localhost/site/?page_id=43&id=3
i only get this on my page {"result":[]}
this is my code. i just need to know how to make mysqli_fetch_array
work in wordpress.
/*
Template Name: getID
*/
global $wpdb;
if (isset($_GET['id']) === true && empty($_GET['id']) === false) {
$query = $wpdb->get_results("SELECT * FROM `memberid` WHERE `memberid` = `$_GET['id']`");
$array = array();
while ($row = mysqli_fetch_array($query)) {
array_push($array, array('name' => $row [2]);
}
echo json_encode(array("result" => $array));
}