当前位置:Gxlcms > 数据库问题 > php示例代码之使用MySQLi接口

php示例代码之使用MySQLi接口

时间:2021-07-01 10:21:17 帮助过:1人阅读

//创建一个mysql连接       if(!$linkID){     echo "<font color=‘red‘>unable to connect!</font>";   }       $SQL_SELECT_SYMBOLS="select * from symbols";       $result=mysqli_query($linkID,$SQL_SELECT_SYMBOLS)or die("error in query :$query. ".mysql_errno()); //执行SQL语句       if(mysqli_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=mysqli_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 "记录未找到!";   }       mysqli_free_result($result); //释放记录集所占用的内存       mysqli_close($linkID); //关闭数据库连接 ?>

技术分享

php示例代码之使用MySQLi接口

标签:

人气教程排行