我沒有從下面的代碼中得到所需的結果。一切正常,但有一個主要問題:當數據庫中沒有歌曲時,它僅通過后退按鈕顯示空結果。它無法顯示回聲“抱歉!” 我們的數據庫中沒有這首歌。我不知道錯誤在哪里。所以請幫忙。提前致謝?。。?lt;?php// Php code that fetches audio from the database in server and shows the audio files with singers available for the submitted data// In submission page DROPDOWN consists of Playlist name and TEXTBOX allows to type the song number for that playlist.// Standard format for the audio file stored in the databse is Songnumber-Playlistname-Singer's Shortname.mp3// MP3 files will be inside the AUDIO folder and this PHP code runs from the root folder where there is index.html file for data submission.// Valid song Numbers of Each Playlists that user choose$validsongnumbers = [ 'Rock' => 3, 'Pop' => 5, 'Jazz' => 6];// Data captured from dropdown submitted by a user in homepage $PlaylistName = $_POST['Dropdown'];$songNumber = $_POST['songnumber'];// Check the playlist existsif (!array_key_exists($PlaylistName, $validsongnumbers)) { echo 'Invalid playlist provided.'; exit;}// Check the song number is not greater than what is allowedif ((int)$songNumber > $validsongnumbers[$PlaylistName]) { echo 'Invalid song number provided.'; exit;}
1 回答

守著星空守著你
TA貢獻1799條經驗 獲得超8個贊
首先,你將“if if”加倍:
if if(count($files) < 0
其次,文件數量永遠不能為負。您應該比較 number 是否等于 0(零),而不是小于 0。
更新:
還是錯誤的代碼:
if ($count=0)
這不是比較,而是賦值。您給出的 $count 值為 0。為了進行比較,您必須使用:
if ($count == 0)
- 1 回答
- 0 關注
- 149 瀏覽
添加回答
舉報
0/150
提交
取消