Phpmyadmin存储例程旨在返回javascript函数中的多行,但返回一行

Phpmyadmin存储例程旨在返回javascript函数中的多行,但返回一行,javascript,php,mysql,Javascript,Php,Mysql,我有一个名为collection\u get\u category\u suggestions的存储例程,它具有以下sql语句 select * from album where category=InCategory; 这将根据用户选择的类别返回多个记录的列表。在sql选项卡中运行时,例程的结果返回多个值,但是在例程选项卡和JavaScript中执行时,它将只返回第一条记录。下面是我处理sql的JavaScript函数 function getCategorySuggestions(cat

我有一个名为collection\u get\u category\u suggestions的存储例程,它具有以下sql语句

select *
from album 
where category=InCategory;
这将根据用户选择的类别返回多个记录的列表。在sql选项卡中运行时,例程的结果返回多个值,但是在例程选项卡和JavaScript中执行时,它将只返回第一条记录。下面是我处理sql的JavaScript函数

function getCategorySuggestions(catid)
{
var categoryid = catid;
    console.log(categoryid);
    selectedcategory = categoryid;
    $("#suggestionsTab").empty();

    var url = "categories_xml.php?category=" + selectedcategory;
        $.ajax({
        type: "GET",
        url: url,
        dataType: "xml",
        success: function(xml){     
            var album_title = $(xml).find('album_title').text();
            console.log(album_title);
            var artist = $(xml).find('artist').text();
            var year = $(xml).find('year').text();
            var imageurl = $(xml).find('imageurl').text();
            var categoryinfo = "<h3>" + album_title + "</h3><p>" + artist + " (" + year + ")</p>";
            //categoryinfo += "<img src='" + imageurl + "' alt='" + album_title + " Album Cover' height='200' width='200' />";  
            console.log(categoryinfo);          
            $('#suggestionsTab').append(categoryinfo);  
        },
        error: function() {
            alert("An error occurred while processing XML file.");
        }
        });
}
foreach循环

foreach($albumsarray as $album)             
            {
                $album_id=$album['album_id'];
                $album_title=$album['album_title'];
                $artist=$album['artist'];               

                $response .= '<album><album_id>' . $album_id . '</album_id><album_title>' . htmlentities($album_title, ENT_QUOTES) . '</album_title><artist>' . htmlentities($artist, ENT_QUOTES) . '</artist></album>';
            }
foreach($albumsarray作为$album)
{
$album_id=$album['album_id'];
$album_title=$album['album_title'];
$artist=$album['artist'];
$response.=''.$album\u id.''.htmlentities($album\u title,entu QUOTES)。''.htmlenties($artist,entu QUOTES)。';
}

Javascript根本不处理SQL。有一个PHP脚本正在处理SQL。如果对AJAX调用的响应仅返回一行,请查看PHP代码以了解原因。是否可以显示PHP代码?您正在从mysql获取所有数据吗?编辑:我不确定,但您的xml节点是否不匹配?我绝对意识到php脚本正在处理此问题。。。我的错误是没有将它添加到答案中-有编辑您可以声明
Collection::GetCategorySuggestions
我们没有使用您的框架。HddnTHA这是对Collection.php的引用吗?我现在已经添加了这个
public static function GetCategorySuggestions($category)
    {
        // Build SQL query
        $sql = 'CALL collection_get_category_suggestions (:category)';

        // Build the parameters array
        $params = array (':category' => $category);

        // Execute the query and return the results
        return DatabaseHandler::GetRow($sql, $params);
    }
foreach($albumsarray as $album)             
            {
                $album_id=$album['album_id'];
                $album_title=$album['album_title'];
                $artist=$album['artist'];               

                $response .= '<album><album_id>' . $album_id . '</album_id><album_title>' . htmlentities($album_title, ENT_QUOTES) . '</album_title><artist>' . htmlentities($artist, ENT_QUOTES) . '</artist></album>';
            }