PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php function para_query($mysqli, $query, $args = []) { $query = str_replace("%s","'%s'",$query); foreach ($args as $key => $val) { $args[$key] = mysqli_real_escape_string($mysqli, $val); } $query = vsprintf($query, $args); $result = mysqli_query($mysqli, $query); return $result; } $query = "SELECT * FROM sakila.film WHERE title like %s LIMIT %d"; $search = ''; $limit = 1; $result = para_query($mysqli, $query, ["%$search%", $limit]); echo json_encode($result->fetch_assoc()); $result = mysqli_query($mysqli, "SELECT * FROM sakila.film LIMIT 1"); echo json_encode($result->fetch_assoc());
Show:  
Copy Clear