Home  >  Article  >  Backend Development  >  读取数据库代码

读取数据库代码

WBOY
WBOYOriginal
2016-06-13 12:56:021027browse

求一个读取数据库代码
求一个独立页面代码 本人不懂编程 不要给提示思路什么的
 先谢谢各位大大mysql账号132 密码456读取库名aa 表名bb 表里的CC列假设读取CC字段前500个数值 读取数值9字符记录有多少个9字符 并且显示到网页上如有10个网页显示10 无则显示0 


------解决方案--------------------
<br />
	@mysql_connect("localhost","123","456");<br />
	@mysql_select_db("aa");<br />
	mysql_query("set names utf8");<br />
	$result=mysql_query("select cc from bb limit 0,500");<br />
	while($row=mysql_fetch_array($result)){  <br />
		$ar[]=$row['cc']; <br />
	}<br />
	$cnt=count($ar);<br />
	for($i=0;$i<$cnt;$i++){<br />
		if($ar[$i]==9){<br />
			$b[]=$i;<br />
		}<br />
	}<br />
	$cnt_b=count($b);<br />
	if($cnt_b>0){<br />
		echo $cnt_b;<br />
	}else{<br />
		echo 0;<br />
	}<br />

------解决方案--------------------
$result=mysql_query("select order_state from order limit 500");<br />
$counter=0;<br />
while($row=mysql_fetch_array($result)){  <br />
    if($row[0]==9) $counter++; <br />
}<br />
echo $counter;
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