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 am 10:34 AM
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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

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

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

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.

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

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

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

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.

How to sort a list using List.Sort function in C# How to sort a list using List.Sort function in C# Nov 17, 2023 am 10:58 AM

How to sort a list using the List.Sort function in C# In the C# programming language, we often need to sort the list. The Sort function of the List class is a powerful tool designed for this purpose. This article will introduce how to use the List.Sort function in C# to sort a list, and provide specific code examples to help readers better understand and apply this function. The List.Sort function is a member function of the List class, used to sort elements in the list. This function receives

What are the common methods of List in Java basics What are the common methods of List in Java basics May 14, 2023 am 10:16 AM

1. Introduction to List interface List is an ordered collection and a repeatable collection. It inherits the Collection interface. Repeated elements can appear in the List collection, and the element at the specified position can be accessed through the index (subscript). 2. List common methods - voidadd (intindex, Obejctelement) method 1. The voidadd (intindex, Obejctelement) method inserts the element element at the specified position and moves the subsequent element back one element. 2.voidadd(intindex,Obejctelemen

See all articles