PHP上的MySQL文本数据限制

时间:2018-08-10 17:56:44

标签: php mysql database mysqli

嗨,我在数据库中存储了一些数据。我的数据库看起来像这样

Database Screenshot file

现在,我使用此代码在表上显示数据。此代码显示表上的所有数据。现在,我只想显示表格中内容库中的前10个字。这是我的代码:

<?php
        $servername = "localhost"; // set your server address.
        $username = "root"; // set your database username 
        $password = ""; // give your db user password 
        $dbname = "admission"; // change this to your data base name

        $conn = mysqli_connect($servername, $username, $password, $dbname);
        mysqli_set_charset($conn,"utf8");

        if (!$conn) {
            die("Connection failed: " . mysqli_connect_error());
        }

        $sql = "SELECT `id`, `type`, `dateadd`, `timeadd`, `versity`, `title`, `content`, `notes` FROM `notices` ORDER BY `notices`.`id` DESC";
        $result = $conn->query($sql);

        if ($result->num_rows > 0) {
             // output data of each row
         while($row = $result->fetch_assoc()) {
           echo "

        <a class='lnkdl' href='Details.php?id=". $row["id"]. "'>
            <div class='dl'>
                <table width='100%'>
                    <td width='20%'>
                        <div class='date'>". $row["dateadd"]. "</div>
                        <div class='time'>". $row["timeadd"]. "</div>
                    </td>
                    <td>
                        <div class='book'>". $row["title"]. "</div>
                        <div class='discripion'>". $row["content"]. "</div>
                    </td>

                </table>
            </div>
        </a> ";
        }
        } else {
         echo "<br><br><br><b>Please try again later <br>or<br>Contact us for this error</b>";
        }
        echo '</table>';
        mysqli_close($conn);
        ?>

1 个答案:

答案 0 :(得分:0)

使用它作为查询:

import (
    "github.com/ethereum/go-ethereum/accounts/abi/bind"
    "strings"
)

const WALLET_PATH string = "path/to/json/wallet"

func main() {

    data, _ := ioutil.ReadFile(WALLET_PATH)
    // up to this point, the program only takes a few MBs of RAM 

    auth, _ := bind.NewTransactor(strings.NewReader(string(data)), "mypassphrase")
    // and here the allocated memory rises up to ~270MB
    _ = auth
}