index.php - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of index.php.php

  1. <?php
  2.         include("connect.php");
  3.  
  4.         if (isset($_POST['btn'])) {
  5.                 $date=$_POST['idate'];
  6.                 $q="select * from grocerytb where Date='$date'";
  7.                 $query=mysqli_query($con,$q);
  8.         }
  9.         else {
  10.                 $q= "select * from grocerytb";
  11.                 $query=mysqli_query($con,$q);
  12.         }
  13. ?>
  14.  
  15. <html>
  16.  
  17. <head>
  18.         <meta http-equiv="Content-Type"
  19.                 content="text/html; charset=UTF-8">
  20.  
  21.         <title>View List</title>
  22.  
  23.         <link rel="stylesheet" href=
  24. "https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
  25.  
  26.         <link rel="stylesheet"
  27.                 href="css/style.css">
  28. </head>
  29.  
  30. <body>
  31.         <div class="container mt-5">
  32.                
  33.                 <!-- top -->
  34.                 <div class="row">
  35.                         <div class="col-lg-8">
  36.                                 <h1>View Grocery List</h1>
  37.                                 <a href="add.php">Add Item</a>
  38.                         </div>
  39.                         <div class="col-lg-4">
  40.                                 <div class="row">
  41.                                         <div class="col-lg-8">
  42.                                                
  43.                                                 <!-- Date Filtering-->
  44.                                                 <form method="post" action="">
  45.                                                         <input type="date"
  46.                                                                 class="form-control"
  47.                                                                 name="idate">
  48.                                                
  49.                                                         <div class="col-lg-4"
  50.                                                                 method="post">
  51.                                                                 <input type="submit"
  52.                                                                 class="btn btn-danger float-right"
  53.                                                                 name="btn" value="filter">
  54.                                                         </div>
  55.                                                 </form>
  56.                                         </div>
  57.                                 </div>
  58.                         </div>
  59.                 </div>
  60.  
  61.                 <!-- Grocery Cards -->
  62.                 <div class="row mt-4">
  63.                         <?php
  64.                                 while ($qq=mysqli_fetch_array($query))
  65.                                 {
  66.                         ?>
  67.  
  68.                         <div class="col-lg-4">
  69.                                 <div class="card">
  70.                                         <div class="card-body">
  71.                                                 <h5 class="card-title">
  72.                                                         <?php echo $qq['Item_name']; ?>
  73.                                                 </h5>
  74.                                                 <h6 class="card-subtitle mb-2 text-muted">
  75.                                                         <?php echo
  76.                                                         $qq['Item_Quantity']; ?>
  77.                                                 </h6>
  78.                                                 <?php
  79.                                                 if($qq['Item_status'] == 0) {
  80.                                                 ?>
  81.                                                 <p class="text-info">PENDING</p>
  82.  
  83.                                                 <?php
  84.                                                 } else if($qq['Item_status'] == 1) {
  85.                                                 ?>
  86.                                                 <p class="text-success">BOUGHT</p>
  87.  
  88.                                                 <?php } else { ?>
  89.                                                 <p class="text-danger">NOT AVAILABLE</p>
  90.  
  91.                                                 <?php } ?>
  92.                                                 <a href=
  93.                                                 "delete.php?id=<?php echo $qq['Id']; ?>"
  94.                                                         class="card-link">
  95.                                                         Delete
  96.                                                 </a>
  97.                                                 <a href=
  98.                                                 "update.php?id=<?php echo $qq['Id']; ?>"
  99.                                                         class="card-link">
  100.                                                         Update
  101.                                                 </a>
  102.                                         </div>
  103.                                 </div><br>
  104.                         </div>
  105.                         <?php
  106.                         }
  107.                         ?>
  108.                 </div>
  109.         </div>
  110. </body>
  111.  
  112. </html>
  113.  
  114.  
File Description
  • index.php
  • PHP Code
  • 23 Sep-2022
  • 2.11 Kb
You can Share it: