У меня есть этот код:
<?php
error_reporting(E_ALL);ini_set('display_errors', 1);
require 'config.php';
$query = $_GET['q'];
if ($query==null) {
exit('No query');
}
$sql = "SELECT title,uploader FROM `uploads_public` ";
if($stmt = $pdo->prepare($sql)){
// Bind variables to the prepared statement as parameters
$stmt->bindParam(":query", $query, PDO::PARAM_STR);
// Attempt to execute the prepared statement
if($stmt->execute()){
echo "Your search $query has the following results(normal PDO:FETCH_ASSOC):<br>";
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
print_r($results);
echo "Here are you <b>real</b> search results:<br>";
} else{
echo "Something went wrong. Please try again later. <br>"; print_r($stmt->errorInfo());
}
// Close statement
unset($stmt);
unset($pdo);
}
else{
die("no input");
}
require 'vendor/autoload.php';
$fuse = new \Fuse\Fuse(($results+= ["keys" => "title"]));
echo("var_dump returns:<br>");
print_r($results);
print_r($fuse->search(".$query."));
Это в основном предназначено для получения данных MySQL и превращения их во что-то как this (т.е. в этом синтаксисе):
[list] => Array
(
[0] => Array
(
[title] => Old Man's War
[author] => John Scalzi
)
[1] => Array
(
[title] => The Lock Artist
[author] => Steve Hamilton
)
[2] => Array
(
[title] => HTML5
[author] => Remy Sharp
)
[3] => Array
(
[title] => Right Ho Jeeves
[author] => P.D Woodhouse
)
)
)
А скорее выводит:
Array
(
[0] => Array
(
[title] => 1548457954
[uploader] => hey
)
[1] => Array
(
[title] => 1548458360
[uploader] => root
)
[2] => Array
(
[title] => first
[uploader] => root
)
[3] => Array
(
[title] => first
[uploader] => root
)
[4] => Array
(
[title] => first
[uploader] => root
)
[5] => Array
(
[title] => first
[uploader] => root
)
[6] => Array
(
[title] => first
[uploader] => root
)
[7] => Array
(
[title] => first
[uploader] => root
)
[8] => Array
(
[title] => first
[uploader] => root
)
[9] => Array
(
[title] => first
[uploader] => root
)
[10] => Array
(
[title] => first
[uploader] => root
)
[11] => Array
(
[title] => RAD
[uploader] => root
)
[12] => Array
(
[title] => RAD
[uploader] => root
)
[13] => Array
(
[title] => GOOD
[uploader] => root
)
[14] => Array
(
[title] => HAVE
[uploader] => root
)
[15] => Array
(
[title] => rad
[uploader] => dboss
)
[16] => Array
(
[title] => rad
[uploader] => dboss
)
[17] => Array
(
[title] => new Image
[uploader] => dboss
)
[18] => Array
(
[title] => My beautiful file
[uploader] => root
)
[19] => Array
(
[title] =>
[uploader] => root
)
[20] => Array
(
[title] => Apple
[uploader] => root
)
[keys] => title
)
Какой дополнительный код мне нужно добавить, чтобы форматировать его так, как я хочу?.........................................................................................................................................................................................................................................