PHP

<?php
// Include the database connection file
require_once "db_connect.php";

$codigo = $_POST["codigo"];

// Use a prepared statement to prevent SQL injection
$stmt = $pdo->prepare("SELECT inartcart, inartnart FROM inart WHERE inartnart LIKE ? ORDER BY inartnart ASC");
$stmt->execute(["%" . $codigo . "%"]);
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);

$html = "";
foreach ($results as $mirow) {
    $html .= "<li onclick=\"mostrar('" . htmlspecialchars($mirow["inartcart"]) . "')\">" . htmlspecialchars($mirow["inartcart"]) . " - " . htmlspecialchars($mirow["inartnart"]) . "</li>";
}
echo json_encode($html, JSON_UNESCAPED_UNICODE);
?>