Check out the codex on wpdb
. In your case, get_row
returns the first row of the result set as an object. There’s no need for any mysqli_*
functions when using $wpdb
.
if ( $result2 )
echo json_encode( $result2 );
And a heads up for SQL injection – use the prepare
method:
$wpdb->get_row(
$wpdb->prepare(
"SELECT * FROM {$myoptionValue['tablename']} WHERE personeelsNummer = %s",
$q
)
);
If personeelsNummer
is an integer, use the placeholder %d
instead of %s