I have developped a "function_autocompletion.php" function that I call from Viewforum_body and Posting_Editor.
I have a phpbb_fr_maps_city table where I have a 'city_name' and 'forum_name' fields.
Here is the code of "function_autocompletion.php":
Code: Select all
<?php
if(isset($_POST['keywords']))
{
header('Content-type: text/html; charset=iso-8859-1');
global $db;
$_POST['keywords']=strtoupper ($_POST['keywords']);
$sql = 'SELECT city_name, forum_name
FROM '.phpbb_fr_maps_city."
WHERE city_name LIKE '".$_POST['keywords']."%'";
$req = $db->sql_query_limit($sql, 8);
$i = 0;
echo '<ul class="list_sites">';
while($autoCompletion = $db->sql_fetchrow($req)){
echo '
<li class="site_list">';
echo '<span class="informal" style="display:none">'.$_POST['keywords'].'-idcache</span><div class="keywords">'.$autoCompletion['city_name'].'</div>
</li>';
// on s'arrête s’il y en a trop
if (++$i >= 8)
die('<li></li></ul>');
}
echo '</ul>';
die();
}
?>
I would like to add a constraint in the MySQL request : the 'forum_name' fields value must be equal to the current 'forum_desc' field value to get a result your the MySQL request.
This 'forum_desc' value is always correct (I can display its content whenever desired and it is ok), but don't know how to link it to this MySQL request (adding which code ?, declaring which additional function or block ?).
The idea, just the idea, would be to have something like this, but it is wrong I know, it doesn't work, but here it is :
Code: Select all
<?php
if(isset($_POST['keywords']))
{
header('Content-type: text/html; charset=iso-8859-1');
global $db;
$_POST['keywords']=strtoupper ($_POST['keywords']);
$sql = 'SELECT city_name, forum_name
FROM '.phpbb_fr_maps_city."
WHERE city_name LIKE '".$_POST['keywords']."%' AND forum_name LIKE '".$forum_data['forum_desc']."%'";
$req = $db->sql_query_limit($sql, 8);
$i = 0;
echo '<ul class="list_sites">';
while($autoCompletion = $db->sql_fetchrow($req)){
echo '
<li class="site_list">';
echo '<span class="informal" style="display:none">'.$_POST['keywords'].'-idcache</span><div class="keywords">'.$autoCompletion['city_name'].'</div>
</li>';
// on s'arrête s’il y en a trop
if (++$i >= 8)
die('<li></li></ul>');
}
echo '</ul>';
die();
}
?>
Thanks in advance