array(0=>array('xm'=>'我是特别的'),1=>array('xm'=>'你好'), 2=>array('xm'=>'你好'), 3=>array('xm'" /> array(0=>array('xm'=>'我是特别的'),1=>array('xm'=>'你好'), 2=>array('xm'=>'你好'), 3=>array('xm'">
Home Backend Development PHP Tutorial mysql多个关键字的查询解决思路

mysql多个关键字的查询解决思路

Jun 13, 2016 pm 01:23 PM
array list quot table xm

mysql多个关键字的查询

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->$list="";
    $car = array('name'=>array(0=>array('xm'=>'我是特别的'),1=>array('xm'=>'你好'), 2=>array('xm'=>'你好'), 3=>array('xm'=>'你好')));
    if(!$car['name']){
        $list='Nothing';
    }else{
        $i = 1;
        foreach($car['name'] as $nm)
        {
            if(strstr($list,$nm['xm']) && $i == 1)
            {
                $list = str_replace($nm['xm'],$nm['xm'].$i,$list);
                $list .= $nm['xm'].($i+1).',';
                $i++;
            }else{
                if(strstr($list,$nm['xm']))
                {
                    $list .= $nm['xm'].($i+1);
                    $i++;
                }else{
                    $list .= $nm['xm'].',';
                }
            }
        }
    }
Copy after login


SQL code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->$sql="SELECT * FROM table where table.title in ('$list') limit 0,10";
Copy after login

php输出:我是特别的,你好1,你好2,你好3
mysql查询语句应该怎样写可以使$list生效?或者其他相同效果的查询方法?
新手麻烦各位尽可能的写得详细一些,谢谢。






------解决方案--------------------
你有
$sql="SELECT * FROM table where table.title in ($list) limit 0,10";
我让你贴出
echo $sql;
的结果!拿到就那么难吗?
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to implement Redis List operation in php How to implement Redis List operation in php May 26, 2023 am 11:51 AM

List operation //Insert a value from the head of the list. $ret=$redis->lPush('city','guangzhou');//Insert a value from the end of the list. $ret=$redis->rPush('city','guangzhou');//Get the elements in the specified range of the list. 0 represents the first element of the list, -1 represents the last element, and -2 represents the penultimate element. $ret=$redis->l

Comparison between Sony linkbuds and xm4 Comparison between Sony linkbuds and xm4 Dec 29, 2023 pm 10:08 PM

Both are true wireless headphones released by Sony. If we want to buy them, how do we choose between Sony linkbuds and xm4? In fact, their positioning is completely different. One focuses on appearance design, and the other focuses on noise reduction. How to choose between Sony linkbuds and xm4: Answer: Sony linkbuds and xm4 are two completely different headphones. If you like the compact appearance and personalized design, choose linkbuds. Friends who need powerful active noise reduction headphones are recommended to choose xm4. Comparison between Sony linkbuds and xm4: 1. First of all, linkbuds is an indoor headset with almost no noise reduction ability. 2. The WF-1000XM4 has professional multi-level noise reduction capabilities, which is almost the strongest in the same price range.

Sort array using Array.Sort function in C# Sort array using Array.Sort function in C# Nov 18, 2023 am 10:37 AM

Title: Example of using the Array.Sort function to sort an array in C# Text: In C#, array is a commonly used data structure, and it is often necessary to sort the array. C# provides the Array class, which has the Sort method to conveniently sort arrays. This article will demonstrate how to use the Array.Sort function in C# to sort an array and provide specific code examples. First, we need to understand the basic usage of the Array.Sort function. Array.So

How to convert JSONArray to List in Java How to convert JSONArray to List in Java May 04, 2023 pm 05:25 PM

1: JSONArray to ListJSONArray string to List//Initialize JSONArrayJSONArrayarray=newJSONArray();array.add(0,"a");array.add(1,"b");array.add(2,"c") ;Listlist=JSONObject.parseArray(array.toJSONString(),String.class);System.out.println(list.to

How to convert xm to mp3 format How to convert xm to mp3 format Feb 28, 2023 am 10:58 AM

Method to convert xm to mp3 format: 1. Open the "Format Factory" software and click the "Add File" button on the mp3 function interface; 2. In the opened interface, double-click the xm file in the file manager; 3. Click " Start" button to convert to mp3 format.

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 Jun 13, 2016 am 10:23 AM

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

Simple and clear method to use PHP array_merge_recursive() function Simple and clear method to use PHP array_merge_recursive() function Jun 27, 2023 pm 01:48 PM

When programming in PHP, we often need to merge arrays. PHP provides the array_merge() function to complete array merging, but when the same key exists in the array, this function will overwrite the original value. In order to solve this problem, PHP also provides an array_merge_recursive() function in the language, which can merge arrays and retain the values ​​of the same keys, making the program design more flexible. array_merge

How to use the array_combine function in PHP to combine two arrays into an associative array How to use the array_combine function in PHP to combine two arrays into an associative array Jun 26, 2023 pm 01:41 PM

In PHP, there are many powerful array functions that can make array operations more convenient and faster. When we need to combine two arrays into an associative array, we can use PHP's array_combine function to achieve this operation. This function is actually used to combine the keys of one array as the values ​​of another array into a new associative array. Next, we will explain how to use the array_combine function in PHP to combine two arrays into an associative array. Learn about array_comb

See all articles