MySQL request question

All style (template, theme and imageset) related questions for the new release; advice, feedback here please.
Post Reply
renefeli2
Registered User
Posts: 3
Joined: Fri Mar 09, 2012 3:18 pm

MySQL request question

Post by renefeli2 »

Hi,

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();
	}
?>
It could be ".$forum_data['forum_desc']."%' or ".$_POSTS['forum_desc']."%' or anything else.... and it might be missing functions to be added at the beginning... ??!!


Thanks in advance :oops:

User avatar
bonelifer
Community Team
Community Team
Posts: 118
Joined: Mon Jan 31, 2005 10:41 am

Re: MySQL request question

Post by bonelifer »

Please seek support for this at the MOD Writers Discussion forum on the main board: [3.0.x] MOD Writers Discussion
William Jacoby - Community Team
Knowledge Base | phpBB Board Rules | Search Customisation Database
Please don't contact me via PM or email for phpBB support .

Post Reply