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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

將數(shù)據(jù)從數(shù)據(jù)庫(kù)提取到復(fù)選框中,并獲取所選值PHP

將數(shù)據(jù)從數(shù)據(jù)庫(kù)提取到復(fù)選框中,并獲取所選值PHP

PHP
臨摹微笑 2022-08-05 10:17:32
我是PHP和Mysql的新手。我在Mysql中有一個(gè)名為“has”的表,我存儲(chǔ)了客戶的物理對(duì)齊方式。有兩個(gè)屬性 CustomerID 和 PyhsicalAilmentName 。在注冊(cè)屏幕中,我希望用戶在復(fù)選框中選擇它們。我能夠使用此表單代碼將物理對(duì)齊從數(shù)據(jù)庫(kù)提取到復(fù)選框中。   <form action="includes/signup.inc.php"  style="border:1px solid #ccc;width: 50%;margin: 0 auto" method="post" >            <div class="container" >            <h1>Sign up</h1>            <p>Please fill in this form to create an account.(Your username should start with "C_")</p>                <hr>            <input type="text" name="username" placeholder="Name">            <input type="text" name="user_last_name" placeholder="Last Name">            <input type="text" name="uid" placeholder="Username">            <input type="password" name="pwd" placeholder="Password">            <input type="password" name="pwd-repeat" placeholder="Repeat Password">            <input type="text" name="user_weight" placeholder="Weight(in terms of kilogram)">            <input type="text" name="user_length" placeholder="Length(in terms of cm)">            <input type="text" name="user_age" placeholder="Age">                <p> Phsical Alignments</p>                <?php                    $sql = "select Name from physical_ailment";                    $result = mysqli_query($conn,$sql);                    $i = 0;                    while($db_row = mysqli_fetch_array($result)){                        ?>                        <input type="checkbox" name="check_list[]"> <?php                            echo $db_row["Name"]; ?> <br>                        <?php                        $i++; }                        ?>問(wèn)題是,當(dāng)我打算通過(guò)foreach循環(huán)獲取選定的那些時(shí),它會(huì)根據(jù)所選復(fù)選框的數(shù)量打印“on”。如果用戶選中 3 個(gè)復(fù)選框,則有 3 個(gè)元素為“on”。當(dāng)我選擇2件事時(shí),讓我們說(shuō),并打印輸出,我搜索了很多,但無(wú)法找到解決方案。感謝任何幫助,感謝您的關(guān)注。$_POST['check_list']$_POST['check_list']$_POST['check_list']print_rArray ( [0] => on [1] => on [2] => on )
查看完整描述

1 回答

?
明月笑刀無(wú)情

TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超4個(gè)贊

如果您沒(méi)有為 HTML 中的復(fù)選框提供屬性,則在大多數(shù)瀏覽器中,該屬性將默認(rèn)為“屬性”,以告知您該屬性已被選中。valueon


因此,如果您正在制作復(fù)選框,要求人們檢查他們最喜歡的3種水果。


<input type="checkbox" name="check_list[]"> Banana <br>

<input type="checkbox" name="check_list[]"> Apple <br>

<input type="checkbox" name="check_list[]"> Orange <br>

如果選中所有 3 個(gè),您將擁有Array ( [0] => on [1] => on [2] => on )


現(xiàn)在,如果添加值屬性


<input type="checkbox" name="check_list[]" value="banana"> Banana <br>

<input type="checkbox" name="check_list[]" value="apple"> Apple <br>

<input type="checkbox" name="check_list[]" value="orange"> Orange <br>

如果選中所有3個(gè),您將獲得:Array ( [0] => banana [1] => apple [2] => orange )


你可以在這里閱讀更多關(guān)于這一點(diǎn)的信息:https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#Value


查看完整回答
反對(duì) 回復(fù) 2022-08-05
  • 1 回答
  • 0 關(guān)注
  • 166 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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