Apache使用php查询MySQL数据库
Apache使用php查询MySQL数据库
数据库:
getAllPeopleBornAfter.php
[php]- <?php
- mysql_connect("localhost","root","shiguang");
- mysql_select_db("student");
- $sql = "SELECT * FROM `student` WHERE `scores` > 90";
- $result=mysql_query($sql);
- // 浏览器使用
- while ($fields = mysql_fetch_row($result))
- {
- for ($i=0, $max=sizeof($fields); $i < $max; $i++ )
- echo $fields[$i]." ";
- echo "<br>";
- }
- /*
- // 手机使用
- while($e=mysql_fetch_assoc($result))
- $output[]=$e;
- print(json_encode($output));
- */
- mysql_close();
- ?>
PS:都是很简单的东西,只是想边学习边做笔记。高手请绕道!
评论暂时关闭