Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

foreach() argument must be of type array|object, bool given. How can i join another table where a where clause also must be there.?

 $SQL = "SELECT * FROM note_list JOIN `notemaker_tables` ON note_list.notemaker_id=notemaker_tables.notemaker_id WHERE notemaker_id = '$notemaker_id';";
    $result = $con->query($SQL);
    
        ?>
        <?php
        
                <!-- Featured Project Row-->
                
                <h1 class="text-white">Notes By <?php echo $notemaker_id; ?></h1><br>
                <?php
                
                foreach ($result as $r) {
                    ?>
                     <div class="row align-items-center no-gutters mb-4 mb-lg-5">
                    <div class="col-xl-8 col-lg-7"> <iframe id="pdf-js-viewer" src="dashboard/note-pdf/<?php echo $r['note']; ?>" title="webviewer" frameborder="0" width="500" height="600"></iframe></div>
                     <div class="col-xl-4 col-lg-5">
                        <div class="featured-text text-center text-lg-left">
                          <p class="text-white"> <?php echo $r['uni_id']; ?> University <br><?php echo $r['depart_id']; ?> Department<br><?php echo $r['subject_id']; ?> Subject<br> <?php echo $r['semester']; ?> Semester</p><br>
                <a href="dashboard/note-pdf/<?php echo $r['note']; ?>" target="_blank" class="btn btn-success">FullScreen</a><br><br><br><br><br><br></div></div>
            </div>
            <hr style="border-width:2;color:white;background-color:white"><br>
                <?php
 }
    } 
    
  }
 ?>

i have to use a where clause also and have to join two tables too.how can i do that.when i write as given , it says foreach() argument must be of type array|object, bool given.when i remove the join statement, the code works.

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

in case $result = $con->query($SQL); is bool (ex false), your query or database connection is failed.

in your WHERE clause the notemaker_id have no table name, replace it with note_list.notemaker_id and it should work.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading