Originally Said By: Ray Borduin
<?php require_once('../Connections/hadithbd.php'); ?>
<?php require_once('../webassist/mysqli/rsobj.php'); ?>
<?php
$hadithBooksList = new WA_MySQLi_RS("hadithBooksList",$hadithbd,0);
$hadithBooksList->setQuery("SELECT hadithbook.BookID, hadithbook.totalHadith, hadithbook.BookNameBD, Count(hadithsection.BookID) AS totalSection FROM hadithbook LEFT OUTER JOIN hadithsection ON hadithbook.BookID = hadithsection.BookID WHERE hadithbook.Active = 1 GROUP BY hadithsection.BookID ORDER BY hadithbook.priority ASC");
$hadithBooksList->execute();
?>
<?php
while (!$hadithBooksList->atEnd()) {
?>
<?php
$sectionList = new WA_MySQLi_RS("sectionList",$hadithbd,0);
$sectionList->setQuery("SELECT hadithsection.SectionBD FROM hadithsection WHERE hadithsection.BookID = ?");
$sectionList->bindParam("i", "".($hadithBooksList->getColumnVal("BookID")) ."", "-1"); //WAQB_Param1
$sectionList->execute();
?>
<?php
$hadithBooksList->Results[$hadithBooksList->Index]["Sections"] = $sectionList->Results;
$hadithBooksList->moveNext();
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Generate Hadith Books JSON File</title>
</head>
<body>
<?php
header("Content-Type: application/json; charset=UTF-8");
die(json_encode($hadithBooksList->Results, JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES));
?>
</body>
</html>
Just a little more of your kind support further needed please. I am trying to just include the "chapterList" query under the "sectionList" query for one more step nested JSON. Please give me one more final push here to overcome the whole things. Thanks a lot Ray!
<?php require_once('../Connections/hadithbd.php'); ?>
<?php require_once('../webassist/mysqli/rsobj.php'); ?>
<?php
$hadithBooksList = new WA_MySQLi_RS("hadithBooksList",$hadithbd,0);
$hadithBooksList->setQuery("SELECT hadithbook.BookID, hadithbook.totalHadith, hadithbook.BookNameBD, Count(hadithsection.BookID) AS totalSection FROM hadithbook LEFT OUTER JOIN hadithsection ON hadithbook.BookID = hadithsection.BookID WHERE hadithbook.Active = 1 GROUP BY hadithsection.BookID ORDER BY hadithbook.priority ASC");
$hadithBooksList->execute();
?>
<?php
while (!$hadithBooksList->atEnd()) {
?>
<?php
$sectionList = new WA_MySQLi_RS("sectionList",$hadithbd,0);
$sectionList->setQuery("SELECT hadithsection.SectionID, hadithsection.SectionBD FROM hadithsection WHERE hadithsection.BookID = ? ORDER BY hadithsection.SectionID ASC");
$sectionList->bindParam("i", "".($hadithBooksList->getColumnVal("BookID")) ."", "-1"); //WAQB_Param1
$sectionList->execute();
?>
<?php
$chapterList = new WA_MySQLi_RS("chapterList",$hadithbd,0);
$chapterList->setQuery("SELECT hadithchapter.SectionID, hadithchapter.ChapterBG, hadithchapter.ChapterAR, hadithchapter.ChapterEN FROM hadithchapter WHERE hadithchapter.StatusActive = 1 AND hadithchapter.BookID = ? AND hadithchapter.SectionID = ? ORDER BY hadithchapter.chapID ASC");
$chapterList->bindParam("i", "".($hadithBooksList->getColumnVal("BookID")) ."", "-1"); //WAQB_Param1
$chapterList->bindParam("i", "".($sectionList->getColumnVal("SectionID")) ."", "-1"); //WAQB_Param2
$chapterList->execute();
?>
<?php
$hadithBooksList->Results[$hadithBooksList->Index]["Sections"] = $sectionList->Results;
$hadithBooksList->moveNext();
}
?>
<?php
header("Content-Type: application/json; charset=UTF-8");
$json = json_encode($hadithBooksList->Results, JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
//die(json_encode($hadithBooksList->Results, JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES));
file_put_contents("hadith_books_section_chapter.json", $json);
?>