zoukankan      html  css  js  c++  java
  • 每日总结

    1.AJAX 与 MySQL

    HTML页面重要代码:

    if (str=="") { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) { // IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码 xmlhttp=new XMLHttpRequest(); } else { // IE6, IE5 浏览器执行代码 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","getsite_mysql.php?q="+str,true); xmlhttp.send();

    PHP 文件:

    <?php $q = isset($_GET["q"]) ? intval($_GET["q"]) : ''; if(empty($q)) { echo '请选择一个网站'; exit; } $con = mysqli_connect('localhost','root','123456'); if (!$con) { die('Could not connect: ' . mysqli_error($con)); } // 选择数据库 mysqli_select_db($con,"test"); // 设置编码,防止中文乱码 mysqli_set_charset($con, "utf8"); $sql="SELECT * FROM Websites WHERE id = '".$q."'"; $result = mysqli_query($con,$sql); echo "<table border='1'> <tr> <th>ID</th> <th>网站名</th> <th>网站 URL</th> <th>Alexa 排名</th> <th>国家</th> </tr>"; while($row = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['id'] . "</td>"; echo "<td>" . $row['name'] . "</td>"; echo "<td>" . $row['url'] . "</td>"; echo "<td>" . $row['alexa'] . "</td>"; echo "<td>" . $row['country'] . "</td>"; echo "</tr>"; } echo "</table>"; mysqli_close($con); ?>
     
     
  • 相关阅读:
    .Net 应用中使用dot trace进行性能诊断
    MyBatis批量增删改查操作
    hadoop2.7.2基于centos全然分布式安装
    HDOJ 3666 THE MATRIX PROBLEM 差分约束
    BZOJ1635: [Usaco2007 Jan]Tallest Cow 最高的牛
    BZOJ1089: [SCOI2003]严格n元树
    BZOJ1406: [AHOI2007]密码箱
    BZOJ1270: [BeijingWc2008]雷涛的小猫
    BZOJ1211: [HNOI2004]树的计数
    BZOJ2729: [HNOI2012]排队
  • 原文地址:https://www.cnblogs.com/chenghaixiang/p/14912379.html
Copyright © 2011-2022 走看看