PHP怎么同时查询多个ID?

WBOY
Release: 2016-06-23 14:03:07
Original
1435 people have browsed it

<?phpinclude 'include/cmsdj.conn.php'; $CD_ID=SafeRequest('id','get');        global $db;        $sql='Select * from '.tname('dj').' where CD_ID='.$CD_ID.'';        $row=$db->getrow($sql);        $server=$db->getrow('select * from '.tname('server').' where CD_ID='.$row['CD_Server'].'');        if($row){                $CD_Url=$row['CD_Url'];                        $playurl=$server['CD_Url'].$CD_Url;        echo '<list><m src="'.$playurl.'" label="'.$row['CD_Name'].'"/></list>';}?>
Copy after login


上面代码是只读取单个ID的
显示
XX.php?id=5555

如果我要它显示多个ID的结果呢?
比如:xx.php?id=5555,6666,1111
相对显示的是



要怎么整呢?


回复讨论(解决方案)

in(5555,6666,1111)

in(5555,6666,1111)

上面的是查到两个表的,不会写啊

global $db;$ar=explode(',',$CD_ID);foreach($ar as $CD_ID){        $sql='Select * from '.tname('dj').' where CD_ID='.$CD_ID.'';        $row=$db->getrow($sql);        $server=$db->getrow('select * from '.tname('server').' where CD_ID='.$row['CD_Server'].'');        if($row){                $CD_Url=$row['CD_Url'];                        $playurl=$server['CD_Url'].$CD_Url;        echo '<list><m src="'.$playurl.'" label="'.$row['CD_Name'].'"/></list>';}}
Copy after login

PHP code
?



1234567891011

global $db; $ar=explode(',',$CD_ID); foreach($ar as $CD_ID){         $sql='Select * from '.tname('dj').' where CD_ID='.$CD_ID.'';         $row=$db->getrow($sql);   …… 谢谢了。怎么把那点给你啊?

PHP code
?



1234567891011

global $db; $ar=explode(',',$CD_ID); foreach($ar as $CD_ID){         $sql='Select * from '.tname('dj').' where CD_ID='.$CD_ID.'';         $row=$db->getrow($sql);   ……

这样得出来的结果是。链在一起的。。。

可以像下面这样分行显示吗?



echo ''."\n";

source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template