I am trying to run a stored procedure using PHP. I want to put the results of the query into a javascript object. I cannot find how to accomplish this. I have run this code but I get one of the results I am returning is undefined. Here is my code:
$result = mysql_query("call sp_getGenre()");
if($result === FALSE){
die(mysql_error());
}
while($row = mysql_fetch_array($result)){
?>
<script type="text/javascript">
console.log(<? $row['Type'] ?>);
var genreObj = new Object();
genreObj.name = "<? echo $row['Type'] ?>";
genreObj.level = <? echo $row['Level'] ?>;
<?
$parentID = $row['PrevID'];
if($parent == null){ $parent = "0"; }
?>
genreObj.parent = <? $parent ?>;
arrGenre.push(genreObj);
</script>
<?
}
?>
I am fairly new to the PHP world but would greatly appreciate a point in the right direction. Thanks in advance.