zoukankan      html  css  js  c++  java
  • 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();
    ?>
  • 相关阅读:
    Luogu P2495 [SDOI2011]消耗战
    40. Combination Sum II
    39. Combination Sum
    22. Generate Parentheses
    51. N-Queens
    Codeforces Round #346 (Div. 2) E. New Reform
    Codeforces Round #346 (Div. 2) D. Bicycle Race
    HDU 5651xiaoxin juju needs help
    VK Cup 2016
    Educational Codeforces Round 10 D. Nested Segments
  • 原文地址:https://www.cnblogs.com/500m/p/11020048.html
Copyright © 2011-2022 走看看