我没有从下面的代码中得到所需的结果。一切正常,但有一个主要问题:当数据库中没有歌曲时,它仅通过后退按钮显示空结果。它无法显示回声“抱歉!” 我们的数据库中没有这首歌。我不知道错误在哪里。所以请帮忙。提前致谢!!!<?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 关注
- 116 浏览
添加回答
举报
0/150
提交
取消