php示例代码之 使用PHP的MySQL标准函数
2016-07-09 13:35
851 查看
<?php //连接参数 $host="localhost"; $user="root"; $pwd="111111"; $db="test"; $linkID =mysql_connect($host,$user,$pwd); //创建一个mysql连接 if(!$linkID){ echo "<font color='red'>unable to connect!</font>"; } mysql_select_db($db)or die("unable to select database"); //选择一个数据库 $SQL_SELECT_SYMBOLS="select * from symbols"; $result=mysql_query($SQL_SELECT_SYMBOLS)or die("error in query :$query. ".mysql_errno()); //执行SQL语句 if(mysql_num_rows($result)>0){ echo '<table cellpadding="10" border="1">'; echo '<tr><th>id</th><th>country</th><th>animal</th><th>cname</th></tr>'; while($row=mysql_fetch_row($result)){ echo "<tr>"; echo "<td>".$row[0]."</td>"; echo "<td>".$row[1]."</td>"; echo "<td>".$row[2]."</td>"; echo "<td>".$row[3]."</td>"; echo "</tr>"; } echo "</table>"; } else{ echo "记录未找到!"; } mysql_free_result($result); //释放记录集所占用的内存 mysql_close($linkID); //关闭数据库连接 ?>
相关文章推荐
- WordPress忘记账户密码最简单的解决方案
- mysql无法远程连接到数据库解决方法
- MySQL事务处理实现方法步骤
- Mysql windows版本的安装
- 2003 - Can connect to MySQL server on localhost (10038)mysql 读取描述文件失败 错误代码:2【亲测可用】
- mysql主从同步延迟优化大全
- 解决Mysql数据库插入数据出现问号(?)的解决办法
- 操作数据表中的记录(增删改查)
- mysql安装图解 mysql图文安装教程(详细说明)
- mysql的备份与恢复
- mysql: update字段中带select
- mysql用户管理
- 线上一个mysql死锁问题
- mysql子查询例子
- RDS MySQL空间优化最佳实践
- MySQL慢日志的学习
- 解决 MySQL 的 Table is marked as crashed and should be repaired 问题
- mysql 主从复制配置
- mysql忘记密码怎么办
- 安装MySQL5.7