我的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(单词)相关联,因此如果用户点击关键词“计算机”,它将与“工程与计算机科学学院”相关联,并将其归入“工程与计算机学院”科学“第一。
这适用于像“教育”这样的其他列,但似乎无法使用我的关联数组。有什么想法吗?
示例sqlfiddle:http://sqlfiddle.com/#!2/c1802/7/0
答案 0 :(得分:1)
以下查询列出了根据需要排序的输出。
SELECT * FROM mediaContacts ORDER BY associations DESC,lname ASC
由于associations
有School of Engineering and Computer Science
作为最后的Alpha记录,所以
如果School of Engineering and Computer Science
不是最后一个alpha记录,则失败并需要另一种方法。
答案 1 :(得分:0)
您可以尝试以下
更改
while ($row = mysqli_fetch_array($sql)) {
到
while ($row = mysql_fetch_assoc($sql)) {
它将返回一个与获取的行对应的关联数组,并将内部数据指针向前移动。