How can i merge both files into a modern aac injection? With a sql connection. Not a standalone connection.
Show.php
With another+js
Injection.php
Show.php
PHP:
<?php
//connection information
$host = "localhost";
$user = "root";
$password = "";
$database = "mod";
$param = $_GET["term"];
//make connection
$server = mysql_connect($host, $user, $password);
$connection = mysql_select_db($database, $server);
//query the database
$query = mysql_query("SELECT name FROM players WHERE name REGEXP '^$param' LIMIT 30");
//build array of results
for ($x = 0, $numrows = mysql_num_rows($query); $x < $numrows; $x++) {
$row = mysql_fetch_assoc($query);
$players[$x] = array("name" => $row["name"]);
}
//echo JSON to page
$response = $_GET["characters"] . "(" . json_encode($players) . ")";
echo $response;
mysql_close($server);
?>
With another+js
Injection.php
PHP:
<?PHP
if ( !defined( 'BASEPATH' ) ) exit( 'No direct script access allowed' );
global $config;
?>
<script>
$(function(){
//attach autocomplete
$("#search").autocomplete({
//define callback search format results
source: function(req, add){
//pass request search server
$.getJSON("/show.php?characters=?", req, function(data) {
//create array for response objects
var suggestions = [];
//process response
$.each(data, function(i, val){
suggestions.push(val.name);
});
//pass array search callback
add(suggestions);
});
},
});
});
function fill(thisValue) {
$('#search').val(thisValue);
}
</script>
<style type="text/css">
#resizable { width: 97%; height: 100px; padding: 0.5em; }
#resizable h3 { text-align: center; margin: 0; height 10px;}
</style>
.... more code