close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Having problem to show Master and child table data

Thread began 4/15/2020 5:12 am by Rokon | Last modified 4/15/2020 1:31 pm by Ray Borduin | 31 views | 6 replies |

Rokon

Having problem to show Master and child table data

I have two table where in one table I have the book category and in another table I have the books name like as below

>>category table
==========
catID
Cat Name


>>books table
========
bookID
catid
bookName


My output need in a repeat region on the page like below;
-------------------------------------------------------

Cat Name A
- bookName1
- bookName 2


Cat Name B
- bookName 3
- bookName 4

I could not figure out how to do this join query so that in my final output I can show data like this, Pls help.

Sign in to reply to this post

Ray BorduinWebAssist

Use two recordsets and filter the child recordset with the id from the parent.

Then do a repeat region on the parent recordset on the page.

After that is applied, manually move the child recordset code inside of the repeat region for the parent.

Now add a repeat region for the child recordset inside of the other repeat region.

Sign in to reply to this post
Did this help? Tips are appreciated...

Rokon

Originally Said By: Ray Borduin
  Use two recordsets and filter the child recordset with the id from the parent.

Then do a repeat region on the parent recordset on the page.

After that is applied, manually move the child recordset code inside of the repeat region for the parent.

Now add a repeat region for the child record set inside of the other repeat region.  



I did like this but the problem arise that on the child it shows always the same record inside all the parent repeat like as below and not changing the books base on the Cat Name.

Cat Name A
- bookName1
- bookName 2
- bookName 3


Cat Name B
- bookName1
- bookName 2
- bookName 3

Sign in to reply to this post

Ray BorduinWebAssist

That means that the child recordset isn't inside of the repeat region or isn't filtered by the parent recordset properly. I'd have to see a copy of the page to know which.

Sign in to reply to this post
Did this help? Tips are appreciated...

Rokon

Originally Said By: Ray Borduin
  That means that the child recordset isn't inside of the repeat region or isn't filtered by the parent recordset properly. I'd have to see a copy of the page to know which.  



The parent query is
===============
<?php
$booksections = new WA_MySQLi_RS("booksections",$hadithbd,0);
$booksections->setQuery("SELECT books_type.btypeID, books_type.bookCat, Count(books_name.booktype) AS Countbooktype, books_name.booktype FROM books_type LEFT OUTER JOIN books_name ON books_type.btypeID = books_name.booktype WHERE books_name.Active = 1 GROUP BY books_name.booktype ORDER BY books_name.booktype ASC");
$booksections->execute();
?>

The child query is
=============
<?php
$booksname = new WA_MySQLi_RS("booksname",$hadithbd,0);
$booksname->setQuery("SELECT books_name.bookID, books_name.booktype, books_name.Book_nameBD, book_writter.writter_nameBN FROM books_name LEFT OUTER JOIN book_writter ON books_name.writterID = book_writter.wrID WHERE books_name.booktype = ? ORDER BY books_name.booktype ASC, books_name.bookID ASC");
$booksname->bindParam("i", "".($booksections->getColumnVal("booktype")) ."", "-1"); //WAQB_Param1
$booksname->execute();
?>

The body is
=========

<div class="row">

<?php
$wa_startindex = 0;
while(!$booksections->atEnd()) {
$wa_startindex = $booksections->Index;
?>

<div class="list-group col-sm">
<div class="list-group-item list-group-item-action active">
<span class="badge badge-pill badge-light float-left"> <i class="fas fa-box-open"></i> <?php echo($booksections->getColumnVal("btypeID")); ?> </span>
<span class="text-center text-white ml-3"><?php echo($booksections->getColumnVal("bookCat")); ?></span> <span class="badge badge-warning text-white float-right"><?php echo($booksections->getColumnVal("Countbooktype")); ?></span>


<?php
$wa_startindex = 0;
while(!$booksname->atEnd()) {
$wa_startindex = $booksname->Index;
?>
<a href="#" class="list-group-item list-group-item-action"><?php echo($booksname->getColumnVal("Book_nameBD")); ?> - <?php echo($booksname->getColumnVal("writter_nameBN")); ?></a>

</div> <?php
$booksname->moveNext();
}
$booksname->moveFirst(); //return RS to first record
unset($wa_startindex);
unset($wa_repeatcount);
?>



<?php
$booksections->moveNext();
}
$booksections->moveFirst(); //return RS to first record
unset($wa_startindex);
unset($wa_repeatcount);
?>

</div>
</div>

Sign in to reply to this post

Ray BorduinWebAssist

Copy and paste the child recordset code in code view inside of the repeat region for the parent recordset so that it is re-generated each time it is displayed. It looks like you missed that step.

Sign in to reply to this post
Did this help? Tips are appreciated...

Rokon

Originally Said By: Ray Borduin
  Copy and paste the child recordset code in code view inside of the repeat region for the parent recordset so that it is re-generated each time it is displayed. It looks like you missed that step.  



Yes, once copy the query inside the repeat region then it works. Thanks.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...