Home  >  Article  >  Backend Development  >  php中怎么取得数组的值

php中怎么取得数组的值

WBOY
WBOYOriginal
2016-06-13 13:13:18838browse

php中如何取得数组的值
我有一个从表contents2取得name这个值
$result=mysql_query("select a.name from contents2 a where a.level$myrow=mysql_fetch_array($result);
从这个得出的name有好几个值,例如:张三1、张三2、张三3
我需要在contents3中根据name查值,请问sql语句怎么写?
$result2=mysql_query("select * from contents3 a where a.name=?")
就是如何把array的值如何放到 a.name=?这儿

------解决方案--------------------
$myrow=mysql_fetch_array($result);
=》
while($myrow=mysql_fetch_array($result)){
$arr[]=$myrow[0];
}

$s="'".join("','",$arr)."'";
$result2=mysql_query("select * from contents3 a where a.name in($s)")

------解决方案--------------------
可以直接把sql语句查询的结果不用取出来直接把结果放在select in()括号里面,这样就没有取得数组值的烦恼了。

Statement:
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