第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

PHP 數(shù)組未顯示在頁面中

PHP 數(shù)組未顯示在頁面中

PHP
慕的地10843 2023-06-24 19:17:54
注釋列表應(yīng)顯示在 ul li 范圍內(nèi),有什么原因說明它們沒有顯示,而是數(shù)組顯示在頁面頂部?數(shù)據(jù)庫連接似乎工作得很好,但是注釋沒有顯示在跨度內(nèi)。它還刪除了“您尚未添加任何注釋文本”代碼<?phprequire_once 'app/init.php';$notesQuery = $db->prepare("    SELECT ID, note    FROM notes");$notesQuery->execute();$notes = $notesQuery->rowCount() ? $notesQuery : [];foreach($notes as $note) {    print_r($note);}?><!DOCTYPE html><html><head>    <meta charset="UTF-8">    <meta name="viewport" content="width=device-width, initial-scale=1.0">    <title>Notes</title>    <link rel="stylesheet" href="styles.css"></head><body>    <header>        <h1>myNotes</h1>        <nav>            <a href="index.php">Home</a>            <a href="about.html">About</a>            <a href="contact.html">Contact</a>        </nav>    </header>     <div class="container">        <form action="add.php" method="post">                 <textarea name="note" placeholder="Insert a note..." autocomplete="off" required></textarea>                <input type="submit" value="Add" />        </form>        <div class="notes">            <h2>Notes</h2>            <?php if(!empty($notes)): ?>            <ul>                <?php foreach($notes as $note): ?>                    <li>                        <span><?php echo $note['note']; ?></span>                    </li>                <?php endforeach; ?>            </ul>                <?php else: ?>                    <p>you haven't added any notes yet.</p>                <?php endif; ?>        </div>
查看完整描述

2 回答

?
FFIVE

TA貢獻(xiàn)1797條經(jīng)驗(yàn) 獲得超6個贊

請隨意使用下面的示例作為您的查詢。


// Your sql query

$sql  = "SELECT ID, note FROM notes";


// Prepare your statement

$stmt = $db -> prepare($sql);


// Execute your prepared statement

$stmt -> execute();


// Retreive all rows

$notes = $stmt -> fetchAll();


// Check if array is not empty

if (!empty($notes)) {

    //Spit out the array

    print_r($notes);

}


查看完整回答
反對 回復(fù) 2023-06-24
?
慕雪6442864

TA貢獻(xiàn)1812條經(jīng)驗(yàn) 獲得超5個贊

工作代碼


<?php


require_once 'app/init.php';


$notesQuery = $db->prepare("

    SELECT ID, note

    FROM notes

");


$notesQuery->execute();


$notes = $notesQuery->rowCount() ? $notesQuery : [];



?>

<!DOCTYPE html>

<html>

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Notes</title>

    <link rel="stylesheet" href="styles.css">

</head>

<body>

    <header>

        <h1>myNotes</h1>

        <nav>

            <a href="index.php">Home</a>

            <a href="about.html">About</a>

            <a href="contact.html">Contact</a>

        </nav>

    </header> 

    <div class="container">

        <form action="add.php" method="post"> 

                <textarea name="note" placeholder="Insert a note..." autocomplete="off" required></textarea>

                <input type="submit" value="Add" />

        </form>

        <div class="notes">

            <h2>Notes</h2>


            <?php if(!empty($notes)): ?>


            <ul>

                <?php foreach($notes as $note): ?>

                    <li>

                        <span><?php echo $note['note']; ?></span>

                    </li>

                <?php endforeach; ?>

            </ul>

                <?php else: ?>

                    <p>you haven't added any notes yet.</p>

                <?php endif; ?>

        </div>

    </div>

</body>

</html>


查看完整回答
反對 回復(fù) 2023-06-24
  • 2 回答
  • 0 關(guān)注
  • 142 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號