• PHP ~ 原生语法 ~ 根据从数据库查询数据之后快速输出 某个属性的值到 到页面


    一,根据 id 来查询单个的数据

    <?php

      require_once '../../conn.php';
    $sql = "select * from blogarticle where ID = {$ID}";   
    $results = mysql_query($sql);
    $blog = mysql_fetch_assoc($results);     //将数值存储到 $blog中
     mysql_free_result($results);

    ?>

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    </head>
    <body>
         <h1>name : <?php echo $blog['name']; ?>  </h1>
    </body>
     
    二,输出表的所有数据
    <?php
           require_once '../conn.php'; 
        
           @$sql = "select * from blogarticle";
          
           @$results = mysql_query($sql);
     
           while (@$row = mysql_fetch_assoc($results)) {
     
             echo <<<s
              
               <tr>
                <td>{$row['title']}</td>
                <td>{$row['content']}</td>
                <td>{$row['class']}</td>
                <td>{$row['author']}</td>
                <td>{$row['date']}</td>
        <td>
         <a href="../logic/article/delete.php?ID={$row['ID']}">删除&nbsp;</a>|
      <a href="../logic/article/update.php?ID={$row['ID']}">修改</a>
        </td>
              </tr>
    s;
    }
      mysql_close();
    ?>
  • 相关阅读:
    淡入淡出js
    Comparable和Comparator的区别
    mybatis的动态sql详解
    mybatis动态sql之foreach
    mybatis的动态sql中collection与assoction
    Mybatis中#与$区别
    转JSONObject put,accumulate,element的区别
    Spring配置,JDBC数据源及事务
    销毁session
    IIS express 7.5 设置默认文档
  • 原文地址:https://www.cnblogs.com/500m/p/11020048.html
Copyright © 2020-2023  润新知