Home > Backend Development > PHP Tutorial > 这样的两个话语能否结合为一句

这样的两个话语能否结合为一句

WBOY
Release: 2016-06-13 12:07:03
Original
925 people have browsed it

这样的两个语句能否结合为一句。

$get_rows = mysql_num_rows("select id from news where class_type='类别'");<br /><br />if($get_rows){<br />  $get_list=mysql_fetch_array("select * from news where class_type='类别'");<br />  .......循环显示<br />}
Copy after login

------解决思路----------------------
很遗憾,非但不能合并为一句,相反要分作三句
$rs = mysql_query("select id from news where class_type='类别'");<br />if($get_rows = mysql_num_rows($rs)) {<br />  $get_list = mysql_fetch_array($rs);<br />  .......循环显示<br />}
Copy after login

------解决思路----------------------
<br />$rs = mysql_query("select id from news where class_type='类别'");<br /><br />$get_list = array();<br /><br />while($row = mysql_fetch_array($rs) ){<br />    array_push($get_list, $row['id']);<br />}<br />$get_rows = count($get_list);<br />
Copy after login

Related labels:
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