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

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

queryResults 和其后的多個(gè) if 語(yǔ)句

queryResults 和其后的多個(gè) if 語(yǔ)句

PHP
江戶川亂折騰 2022-06-17 16:18:01
在我的 php 代碼中,我顯示了數(shù)據(jù)庫(kù)的結(jié)果,一切都很好?,F(xiàn)在我添加了一行文本,顯示返回的行數(shù)。我不喜歡它顯示“有 1 個(gè)結(jié)果”和“有 5 個(gè)結(jié)果”等。我做了一個(gè) if 語(yǔ)句“如果 $queryResult = 1”然后回顯“有 1 個(gè)結(jié)果”,還有 "if $queryResult > 1" echo "There are xx results",然后 "if $queryResult > 0" 回顯所有結(jié)果行?,F(xiàn)在,這是代碼,除了在只有 1 個(gè)結(jié)果時(shí)使用不正確的“are”和“results”外,它可以工作:$queryResult = mysqli_num_rows($result);echo "There are ".$queryResult." results.";if ($queryResult > 0) { // output data of each rowwhile($row = mysqli_fetch_assoc($result)) { // Display each field of the records.所以,我嘗試了這段代碼:$queryResult = mysqli_num_rows($result);//echo "There are ".$queryResult." results.";if ($queryResult = 1) {echo "There was ".$queryResult." lesson found.";}elseif ($queryResult > 1) {echo "There were ".$queryResult." lessons found.";}else ($queryResult > 0) { // output data of each rowwhile($row = mysqli_fetch_assoc($result)) { // Display each field of the records.它打破了頁(yè)面,出現(xiàn)以下錯(cuò)誤:語(yǔ)法錯(cuò)誤,意外的'while'(T_WHILE)我敢肯定還有更多錯(cuò)誤,我敢肯定我錯(cuò)過(guò)了關(guān)于第一個(gè)if和elseif語(yǔ)句的一些東西,但是什么是嗎?我究竟做錯(cuò)了什么?我還在花括號(hào)中包含了第一個(gè) if 和 elseif 語(yǔ)句,但這也不起作用。我知道使用“is”和“are”之間的區(qū)別是微不足道的,但這是在一個(gè)網(wǎng)站上為學(xué)習(xí)英語(yǔ)作為第二語(yǔ)言的人使用的,這意味著它應(yīng)該正確使用英語(yǔ)。并且“有 1 個(gè)結(jié)果”對(duì)于新學(xué)習(xí)者來(lái)說(shuō)并不是很好的英語(yǔ)。
查看完整描述

1 回答

?
慕田峪7331174

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

您的代碼中有一些語(yǔ)法錯(cuò)誤,其中之一是您將您設(shè)置$queryResult為1:


if ($queryResult = 1) 

你要:


if ($queryResult == 1) 

但是,像這樣壓縮代碼更容易:


$rsltCount = mysqli_num_rows($result);

echo  $rsltCount === 1 ? "There is 1 result." : "There are ".$rsltCount." results.";


while($row = mysqli_fetch_assoc($result)) 

    // Display each field of the records.

}


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

添加回答

舉報(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)