So, you didn't help me but I'm a really nice guy and give you my solution
Input Field Type : Multiline textbox
Allow multiple values for this field : yes
Use Custom Input HTML : yes
Input Field HTML :
I used my own ajax_authors.php (see below) because it's an external DB (not in mybb_structure) and I didn't want to modify xmlhttp.php
Display Parsing : Plain text with new lines
Multiple Value Delimiter : &
ebook_newthread :
ajax_authors.php :
(Notice that I've a small trouble in render, the lines after the first one begins with a space)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
<?php
try {
// It's an example, you can use mybb conf and db object
$db['host'] = 'localhost';
$db['base'] = 'mybase';
$db['user'] = 'myuser';
$db['pass'] = 'mypass';
$pdo = new PDO("mysql:host=".$db['host'].";dbname=".$db['base'], $db['user'], $db['pass']);
} catch (PDOException $e) {
echo "Failed to get DB handle: " . $e->getMessage() . "\n";
exit;
}
// Send no cache headers
header("Expires: Sat, 1 Jan 2000 01:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header("Content-type: text/plain; charset=utf8");
if (isset($_GET['query']) && strlen($_GET['query'])>3) {
$q = str_replace(array(' ', '&'), array('', ''), $_GET['query']);
$query = $pdo->prepare("SELECT aid, aname FROM ref_authors WHERE aname LIKE :aname AND valid=1");
$query->execute(array(':aname' => '%'.$q.'%'));
$authList = array();
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
echo '<div>', PHP_EOL, '<span class="authname">', utf8_encode($row['aname']), '</span>', PHP_EOL, '</div>', PHP_EOL;
}
}
|
I'll try to correct some small bugs, but it works