How do I get a report of this data?

How do I get a report of this data

There is one ‘Screw’ in the database but it shows two ‘Screw and Cement’. What is the problem?
Is it right to receive a report in this way?

source code

<?php include_once 'header.php'; ?>
<?php include_once 'sidebar.php'; ?>
<?php include_once 'navtop.php'; ?>
                <div class="container-fluid">
                  <?php

                  $ff=output(@$_GET['ff']);
                  $ss=output(@$_GET['ss']);
                  $tyy=output(@$_GET['tyy']);
                  $fdate=output(@$_GET['fdate']);
                  $tday=output(@$_GET['tday']);

                  if (isset($_GET['class'])) {
                    ?>
                  <div class="card shadow mb-4">
                    <div class="card-header py-3">
                    </div>
                    <div class="card-body">
                      <form method="get">

                        <div class="form-group">
                          <label for="email">Fixation Type:</label>
                            <select class="form-control" name="ff" id="class_id">
                              <option value="0" >choose</option>
                              <option value="Screw">Screw</option>
                              <option value="Cement">Cement</option>
                           </select>
                        </div>

                        <div class="form-group">
                          <label for="name">Size:</label>
                          <input type="text" name="ss" value="" class="form-control" id="student_name" placeholder="Diameter">
                        </div>
                        <hr>
                        <div class="form-group">
                            <label for="email">Type of crown:</label>
                            <select class="form-control" name="tyy" id="class_id">
                              <option value="0" >choose</option>
                              <option value="ceramic">ceramic</option>
                              <option value="zirconium">zirconium</option>
                              <option value="Acrylic">Acrylic</option>
                              <option value="Emax">Emax</option>
                              <option value="Veneer">Veneer</option>
                              <option value="other">other</option>
                           </select>
                        </div>
                        <div class="form-group">
                              <label>From Date</label>
                              <input type="text" name="fdate" class="form-control" value="" id="fdate">
                         </div>

                         <div class="form-group">
                              <label>To Date</label>
                             <input type="text" name="tday" class="form-control" value="" id="tday">
                         </div>
                         <div class="form-group" align="center">
                            <input type="submit" name="class" class="btn btn-primary btn-sm btn-block">
                         </div>
                        </form>
                            <?php
                            $stm = $db->prepare("SELECT * FROM patient WHERE fixation_t=:ff or Size=:ss or (registration_d between :fdate and :tday AND type_of_c=:tyy)");
                            $stm->bindParam(":ff",$ff, PDO::PARAM_STR);
                            $stm->bindParam(":ss",$ss, PDO::PARAM_STR);
                            $stm->bindParam(":tyy",$tyy, PDO::PARAM_STR);
                            $stm->bindParam(":fdate",$fdate, PDO::PARAM_STR);
                            $stm->bindParam(":tday",$tday, PDO::PARAM_STR);
                            //$stm->bindParam(":sn",$sn, PDO::PARAM_STR);
                            $stm->execute();
                            $rowCount = $stm->rowCount();
                            if($rowCount > 0){
                            ?>
                              <div class="table-responsive">
                              <h5 align="center">patient Report from <?php echo $fdate?> to <?php echo $tdate?></h5>
                              <table class="table table-bordered" id="dataTables-example">
                                  <thead>
                                    <tr>
                                      <th>#</th>
                                      <th>Name</th>
                                      <th>birth</th>
                                      <th>Fixation Type</th>
                                      <th>Doctor</th>
                                      <th>No:Impalnt</th>
                                      <th>Implant System</th>
                                      <th>Cost</th>
                                      <th>Action</th>
                                    </tr>
                                  </thead>
                                  <tbody>
                                    <?php
                                    $results=$stm->fetchAll(PDO::FETCH_ASSOC);
                                    $cnt=1;
                                    $total= 0;
                                      foreach ($results as $row) {
                                      ?>
                                      <tr>
                                          <td><?php echo $row['id']; ?></td>
                                          <td><?php echo $row['name']; ?></td>
                                          <td><?php echo $row['birth']; ?></td>
                                          <td><?php echo $row['fixation_t']; ?></td>
                                          <td><?php echo $row['doctor']; ?></td>
                                          <td><?php echo '<span class="badge badge-pill badge-success">Qty '.$row['Impalnt_n'].'</span>'; ?></td>
                                          <td><?php echo $row['type']; ?></td>
                                          <td>$<?php echo $totalmarks=$row['Cost']; ?></td>
                                          <td>
                                            <a href="edit_pateint.php?id=<?php echo htmlentities($row['id']);?>" class="btn btn-warning btn-sm"><i class="fa fa-edit"></i></a>
                                            <a href="patietlist.php?del=<?php echo $row['id']; ?>" class="btn btn-danger btn-sm"><i class="fa fa-trash"></i></a>
                                          </td>
                                      </tr>

                                      <?php
                                      $totlcount+=$totalmarks;

                                    }?>
                                    <tr>
                                    <th scope="row" colspan="7" style="text-align: center">Total Cost</th>
                                    <td colspan="2" style="text-align: left"><b><?php echo htmlentities($totlcount);?></td>
                                    </tr>
                                    <tr>
                                      <th scope="row" colspan="7" style="text-align: center">count</th>
                                      <td colspan="2" style="text-align: left"><b> <?php echo  $rowCount; ?></td>
                                    </tr>
                                  </tbody>
                              </table>
                          </div>

                          <?php
                        } else {
                            echo 'هیچ ئەنجامێك نەدۆزراوە!';
                          }
                       ?>
                   </div>
               </div>

             <?php } ?>
              </div>
              <script type="text/javascript">
              $('#fromdate').daterangepicker({
                singleDatePicker: true,
                locale: { format: "YYYY-MM-DD" }
                //startDate: moment().subtract(6, 'days')
              });
              </script>
              <script type="text/javascript">
              $('#todate').daterangepicker({
                singleDatePicker: true,
                locale: { format: "YYYY-MM-DD" }
                //startDate: moment().subtract(6, 'days')
              });
              </script>
<?php include_once 'footer.php'; ?>

1 Like

You us or, so you get all rows which has a fixation_t of :ff OR their size match :ss or….

So maybe you want something else but we do not know what

for tthis i have same proble
What is the solution؟

<?php include_once 'header.php'; ?>
<?php include_once 'sidebar.php'; ?>
<?php include_once 'navtop.php'; ?>
                <div class="container-fluid">
                  <?php

                  $ff=output(@$_GET['ff']);
                  $tyy=output(@$_GET['tyy']);
                  //$fdate=output(@$_GET['fdate']);
                  //$tday=output(@$_GET['tday']);

                  if (isset($_GET['class'])) {
                    ?>
                  <div class="card shadow mb-4">
                    <div class="card-header py-3">
                    </div>
                    <div class="card-body">
                      <form method="get">

                        <div class="form-group">
                          <label for="email">Fixation Type:</label>
                            <select class="form-control" name="ff" id="class_id">
                              <option value="0">choose</option>
                              <option <?php va("Screw",$ff); ?>  value="Screw">Screw</option>
                              <option <?php va("Cement",$ff); ?>  value="Cement">Cement</option>
                           </select>
                        </div>

                        <div class="form-group">
                            <label for="email">Type of crown:</label>
                            <select class="form-control" name="tyy" id="class_id">
                              <option value="0" >choose</option>
                              <option <?php va("ceramic",$tyy); ?> value="ceramic">ceramic</option>
                              <option <?php va("zirconium",$tyy); ?> value="zirconium">zirconium</option>
                              <option <?php va("Acrylic",$tyy); ?> value="Acrylic">Acrylic</option>
                              <option <?php va("Emax",$tyy); ?> value="Emax">Emax</option>
                              <option <?php va("Veneer",$tyy); ?> value="Veneer">Veneer</option>
                              <option <?php va("other",$tyy); ?> value="other">other</option>
                           </select>
                        </div>
                         <div class="form-group" align="center">
                            <input type="submit" name="class" class="btn btn-primary btn-sm btn-block">
                         </div>
                        </form>
                            <?php
                            $stm = $db->prepare("SELECT * FROM patient WHERE  fixation_t=:ff || type_of_c=:tyy");
                            $stm->bindParam(":ff",$ff, PDO::PARAM_STR);
                            $stm->bindParam(":tyy",$tyy, PDO::PARAM_STR);
                            //$stm->bindParam(":fdate",$fdate, PDO::PARAM_STR);
                            //$stm->bindParam(":tday",$tday, PDO::PARAM_STR);
                            $stm->execute();
                            $rowCount = $stm->rowCount();
                            if($rowCount > 0){
                            ?>
                              <div class="table-responsive">
                              <table class="table table-bordered" id="dataTables-example">
                                  <thead>
                                    <tr>
                                      <th>#</th>
                                      <th>Name</th>
                                      <th>birth</th>
                                      <th>Fixation Type</th>
                                      <th>Doctor</th>
                                      <th>No:Impalnt</th>
                                      <th>Implant System</th>
                                      <th>Cost</th>
                                      <th>Action</th>
                                    </tr>
                                  </thead>
                                  <tbody>
                                    <?php
                                    $results=$stm->fetchAll(PDO::FETCH_ASSOC);
                                    $cnt=1;
                                    $total= 0;
                                      foreach ($results as $row) {
                                      ?>
                                      <tr>
                                          <td><?php echo $row['id']; ?></td>
                                          <td><?php echo $row['name']; ?></td>
                                          <td><?php echo $row['birth']; ?></td>
                                          <td><?php echo $row['fixation_t']; ?></td>
                                          <td><?php echo $row['doctor']; ?></td>
                                          <td><?php echo '<span class="badge badge-pill badge-success">Qty '.$row['Impalnt_n'].'</span>'; ?></td>
                                          <td><?php echo $row['type']; ?></td>
                                          <td>$<?php echo $totalmarks=$row['Cost']; ?></td>
                                          <td>
                                            <a href="edit_pateint.php?id=<?php echo htmlentities($row['id']);?>" class="btn btn-warning btn-sm"><i class="fa fa-edit"></i></a>
                                            <a href="patietlist.php?del=<?php echo $row['id']; ?>" class="btn btn-danger btn-sm"><i class="fa fa-trash"></i></a>
                                          </td>
                                      </tr>

                                      <?php
                                      $totlcount+=$totalmarks;

                                    }?>
                                    <tr>
                                    <th scope="row" colspan="7" style="text-align: center">Total Cost</th>
                                    <td colspan="2" style="text-align: left"><b><?php echo htmlentities($totlcount);?></td>
                                    </tr>
                                    <tr>
                                      <th scope="row" colspan="7" style="text-align: center">count</th>
                                      <td colspan="2" style="text-align: left"><b> <?php echo  $rowCount; ?></td>
                                    </tr>
                                  </tbody>
                              </table>
                          </div>

                          <?php
                        } else {
                            echo 'not avalable';
                          }
                       ?>
                   </div>
               </div>

             <?php } ?>
              </div>
              <script type="text/javascript">
              $('#fromdate').daterangepicker({
                singleDatePicker: true,
                locale: { format: "YYYY-MM-DD" }
                //startDate: moment().subtract(6, 'days')
              });
              </script>
              <script type="text/javascript">
              $('#todate').daterangepicker({
                singleDatePicker: true,
                locale: { format: "YYYY-MM-DD" }
                //startDate: moment().subtract(6, 'days')
              });
              </script>
<?php include_once 'footer.php'; ?>

What was type_of_c for those two rows?

You are just trying around without any system. Why don’t you answer our question what you want to achieve. If you only want the records with a special fixatation type you should only ask for it and not for other columns. If you need additional matches we need to know what’s the logic

i talked abow same things my bro

Again, without seeing the data, we cant answer you for certain. I suspect that the problem is you’re using OR gates in your query where you dont want to. But I cant assert that without knowing the full data of those returned rows.

It looks like there might be a problem with the data in the database. It’s strange that there are two entries for “Screw and Cement” when there is only one “Screw”. It might be helpful to get a report of this data so that the problem can be identified and fixed.

i fixed it, thanks