select并group后,如何换行显示

WBOY
Release: 2016-06-13 10:35:05
Original
1131 people have browsed it

select并group后,怎么换行显示

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->$result = mysql_query("SELECT * FROM Product group by p_class limit 40");while($row = mysql_fetch_array($result)){ echo nl2br($row['p_class']); }
Copy after login


这样的结果就是把p_class直接一个挨着一个全部显示到一行上了.

我的目的是,每个不同的p_class都要自成一列。

记得在ASP里是用循环搞定的:

[code=ASP] dim iiii

iiii = 1

do while not rs2.eof


%>
 
   
   
 
rs2.movenext
iiii = iiii + 1
loop
%>


 


call rs2close()
call connclose()

%>[/code]

PHP里我还不知道该怎么写,麻烦大家推荐一下,谢谢!

------解决方案--------------------
这个意思?

PHP code
echo '
Copy after login
';echo '';while($row = mysql_fetch_array($result)){ echo ""; }echo '';echo '
$row['p_class']
';
------解决方案--------------------
探讨

php中有类似指针这个说法吗,查了一下循环的写法,貌似还缺个指针的配合

------解决方案--------------------
echo "".nl2br($row['p_class'])."";
------解决方案--------------------
语法 错误

因为你里面还有函数所以得改成这样
echo "".nl2br($row['p_class'])."";

上面的语法错误是因为$row['p_class'] 写成 {$row['p_class']}
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