I made a code in AJAX PHP executes and prints in the HTML the result of the SQL query, the problem is that when it displays on the screen, the data is not treated, look like this:
WhatIneedissimplytodisplayonlythecontentsof'ayzac_episode_name',butIcannotlosetheotherinformation(mainly'ayzac_episode_id')
followthecodes:
AJAX:
functionsearchEpisode(seasonID,divepisodioID){if(window.XMLHttpRequest){req=newXMLHttpRequest();}elseif(window.ActiveXObject){req=newActiveXObject("Microsoft.XMLHTTP");
}
var url = "../control/ayzac_control_getEpisode.php?id=" + seasonID;
req.open("Get", url, true);
req.onreadystatechange = function() {
if (req.readyState == 4 && req.status == 200) {
var answer = req.responseText;
alert(answer);
document.getElementById("episodios" + divepisodioID).innerHTML = answer;
}
}
PHP (function that looks for the episode):
function getSerieEpisodes($seasonID){
$connect = new ControllerConnect ();
$objCon = $connect->controllerConnect ();
$sql = "SELECT * FROM ayzac_episode WHERE ayzac_season_id = '".$seasonID."'";
return $objCon->executeSQLFetchObjectEpisodes($sql);
}
PHP (executeSQLFetchObjectEpisodes):
function executeSQLFetchObjectEpisodes($sql = NULL) {
if ($sql != NULL) {
$query = mysqli_query ( $this->con, $sql );
while ( $result = mysqli_fetch_object ( $query ) ) {
$this->rows [] = $result;
}
if ($this->rows != null) {
return $this->rows;
}
return false;
} else {
return false;
}
}