【发布时间】:2014-01-04 06:09:34
【问题描述】:
我的 profileTable 中有一个名为“Associations”的列...我正在尝试查询与关联相关的配置文件。
$sql = mysqli_query($con,"SELECT * FROM profileTable WHERE Keyword_ID LIKE
'%".$getKeyID."%' ORDER BY Associations <> 'School of Engineering
and Computer Science', Associations AND LaName ASC LIMIT $start,$end");
我可以按教育而不是协会为个人资料编制索引。
while ($row = mysqli_fetch_array($sql)) {
$key = $row['Keyword_Name'];
$keyID = $row['Keyword_ID'];
$fname = $row['FirName'];
$lname = $row['LaName'];
$mname = $row['MName'];
$suffix = $row['Suffix'];
$title = $row['Title'];
$title2 = $row['Title2'];
$title3 = $row['Title3'];
$education = $row['Education'];
$education2 = $row['Education2'];
$education3 = $row['Education3'];
$dept = $row['Dept'];
$phone1 = $row['PH1'];
$phone2 = $row['PH2'];
$email = $row['Email'];
$photo = $row['Photo'];
$bio = $row['BioLK'];
$website = $row['Website'];
$assocs = $row['Associations'];
$actions=array('School of Engineering and Computer Science'=>'Computer Science
and Engineering');
我需要将关联与 $key(word) 相关联,因此如果用户单击关键字“计算机”,它将与“工程与计算机科学学院”相关,并为“工程与计算机学院”中的那些索引科学”第一。
这适用于“教育”等其他列,但似乎无法让它与我的关联数组一起使用。有什么想法吗?
示例 sqlfiddle:http://sqlfiddle.com/#!2/c1802/7/0
【问题讨论】:
-
问题:为什么要将该行解压缩成一百万个变量?
-
?? @Mike'Pomax'Kamermans 解释...
-
不,这就是整个问题。您有一个包含所有数据的数据容器,为什么要将它解压缩为 20 个变量,而不是在需要使用它的代码部分中使用关联数据数组?这只会使您的代码变得不必要地庞大,没有任何实际好处(例如,$title1 与 $data["title1"] 一样清晰)
-
在获得更多答案的相关说明中,您可能还想发布一个sqlfiddle.com 链接以显示您的数据的实际样子,并且查询很容易复制。
-
点赞THIS