来自多个表的PHP MYSQL查询 [英] PHP MYSQL query from multiple tables

查看:83
本文介绍了来自多个表的PHP MYSQL查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我试图进行查询,将要进入我在mysql数据库中的4个表中,它将执行一个下拉列表,其中是一个搜索框,然后人们可以单击一个名称,然后它将打开他们搜索的文档.

这是一个问题,即时通讯仅用一个表就能做到这一点,一旦我尝试包括另一个表就行不通了...

我在网上搜索,但看到一些联接查询,但是这些查询不起作用...这是我的1个表的代码正常工作的原因.
这是一个从html页面调用的文件:(livesearch.mysql.php)

Hi im trying to make a query thats gonna go into 4 tables i have in my mysql data base and it will do a drop down list, wich is a search box, then people can click on a name and it will open the document they searched for.

heres the problem, im capable of doing this with only 1 table, as soon i try to include another table it doesnt work...

i searched the web and i saw some join query but those doesnt work... heres my code for 1 table wich is working.

this is a file that is called from a html page :(livesearch.mysql.php)

<?php                   <br mode="hold" /?>  	//Get the q parameter from URL                          
	$q=$_GET["q"];
	$hint="";

	$link = mysql_connect('*server*', '*username*', '*pswd*');
	if (!$link)
	{
		die('Could not connect: '.mysql_error());
	}
	
	mysql_select_db("*database*");
	
	$query='SELECT * FROM procedures WHERE Nom LIKE "%'.$q.'%"'; 
	
	$result = mysql_query($query);
	$row_count=mysql_num_rows($result);

	while ($row = mysql_fetch_array($result))
	{
		$appName = $row['Nom'];
		$appLink = $row['Lien_Nom'];
		
		if ($hint=="")
		{
			$hint="<a href="".$appLink."" target="_blank">".$appName."</a>";
		}
		else
		{
			$hint=$hint."<br /><a href="".$appLink."" target="_blank">".$appName."</a>";
		}
	}
	
	if ($hint=="")
	{
		$response="no suggestions...";
	}
	else
	{
		$response=$hint;
	}
	                                                                                                                     
	echo $response;   
?>

推荐答案

q =


_GET ["q"];
_GET["q"];


提示=";


这篇关于来自多个表的PHP MYSQL查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆