0

I’d like to display other text in else statement but it seems like the value or html in IF statement in my num_rows are displaying in the else statement as well.

<?php
//
queryChecker = "SELECT SUM(user_rating) as totalrating,  COUNT(user_rating) as user_ratings FROM tbl_userfeedback, tbl_users WHERE tbl_userfeedback.research_uid = '" .row['research_uid'] . "' 
AND tbl_users.user_uid = '" . _SESSION['user_uid'] . "'"; // '" .row['research_uid'] . "'"
sqlChecker = mysqli_query(conn, queryChecker); if (sqlChecker) {
    if (getNumRows = mysqli_num_rows(sqlChecker) > 0) {
        while (loopValue = mysqli_fetch_assoc(sqlChecker)) {
                getavg =loopValue['totalrating'] / loopValue['user_ratings']; ?>             <div class="container" id="wrapperContainer">                 <div class="card">                     <div class="card-header">                         <h3 class="text-center">Featured</h3>                     </div>                     <div class="card-body">                         <h5 class="card-title">This is the summarized and brief feedbacks of all users....</h5>                         Currently, there's a <b><?php echoloopValue['user_ratings'] ?></b>
                            people who gave feedback to this research, averaging. <b><?php echo getavg; ?></b>                         Student: <span>2</span>                         <!-- <a href="#" class="btn btn-primary">Go somewhere</a> -->                     </div>                 </div>             </div>             <div class="line"></div>         <?php         }     } else {          // this should be displayed if num rows found nothing.         ?>         <b>This research/capstone doesn't have any feedback yet.</b> <?php     } } ?> </pre></div><!-- /wp:codemirror-blocks/code-block --> <!-- wp:paragraph -->this is my table structure<!-- /wp:paragraph --> <!-- wp:codemirror-blocks/code-block {"showPanel":false,"languageLabel":"no","mode":"clike","mime":"text\/x-c++src"} --> 			<div class="wp-block-codemirror-blocks-code-block code-block"><pre>SELECT * FROM `tbl_userfeedback`   ID  research_uid                user_uid    user_rating  user_feedback   1   researchUid_609d50e56fd1c   03-1819-01469   5        Very Impressed  2   researchUid_609d50e56fd1c   03-1819-01235   3        Average     3   researchUid_609d50e56fd1c   03-1819-0101    4        Satisfied   4   researchUid_609d50e56fd1c   03-1819-0102    5        Very Impressed  </pre></div><!-- /wp:codemirror-blocks/code-block --> <!-- wp:paragraph -->as you can see in the table structure, <!-- wp:codemirror-blocks/code-block {"showPanel":false,"languageLabel":"no","mode":"clike","mime":"text\/x-c++src"} --> 			<div class="wp-block-codemirror-blocks-code-block code-block"><pre>researchUid_609d50e56fd1c</pre></div><!-- /wp:codemirror-blocks/code-block --> is the only research_uid that is stored in tbl_userfeedback. However. Whenever I try to view other research all of them are going to the while statement... PS: therow['research_uid'] is just the research_uid.

If the research does not existing yet in the tbl_userfeedback this is what it says.

Warning: Division by zero in (directory)helper_getResearchFeedback.php on line 12"

Please do correct me if I am wrong I do not know if I am wrong in conditional statement or in my SQL Query.

Anonymous Asked question May 14, 2021