zoukankan      html  css  js  c++  java
  • php示例代码之 使用PHP的MySQL标准函数

    <?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); //关闭数据库连接
    ?>
    

     

  • 相关阅读:
    java上传文件依赖的jar
    maven创建web项目很慢
    人才的成长与工作环境
    msdtc
    阿里巴巴的ChaosBlade
    集成电路
    晶体管
    PHPStorm如何快捷提交代码到服务器
    PHP 7新特性
    题(3)
  • 原文地址:https://www.cnblogs.com/webenh/p/5655684.html
Copyright © 2011-2022 走看看