在PHP / MySQL查询中创建关联数组

Miz*_*ita 5 php mysql arrays

我的profileTable中有一列称为“关联” ...我正在尝试查询与关联相关的配置文件。

$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");
Run Code Online (Sandbox Code Playgroud)

我能够通过教育而不是协会来索引个人资料。

    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');
Run Code Online (Sandbox Code Playgroud)

我需要将关联与$ key(word)关联,因此,如果用户单击关键字“计算机”,它将与“工程与计算机科学学院”相关联,并首先对“工程与计算机科学学院”中的索引。

这可以与“教育”等其他列配合使用,但似乎无法使其与我的关联数组一起使用。有任何想法吗?

示例sqlfiddle:http ://sqlfiddle.com/#!2/c1802/7/0

dav*_*han 2

以下查询列出了按要求排序的输出。

SELECT * FROM mediaContacts ORDER BY  associations DESC,lname ASC
Run Code Online (Sandbox Code Playgroud)

小提琴

与最后一个 alpha 记录一样,它也有效associationsSchool of Engineering and Computer Science

如果School of Engineering and Computer Science不是最后一个 alpha 记录,则会失败,需要另一种方法。