Show table with conditions from 2 input fields

17
March 16, 2019, at 03:10 AM

I'm having problems showing filtered table under 2 conditions from my database table.

Here I have a normal fully working table, which shows everything(I mean all the data from the table and thats fine) :

  <?php include("konekcija.php");?>    
<?php
    global $connection;
?>
<html>
<head>
    <meta charset="UTF-8">
    <title align="center">Prikaz evidencije</title>
    <?php include("home.php"); ?>

  <div align="center" id="centar">
<input type="button" value="Štampaj evidenciju" class="btn btn-primary" onClick="document.location.href='print.php'" style="font-weight:bold;" /> 
</div>
<body>

   <table width="1000" border="3" align="center" style="width:80%">
       <caption style="text-align:center; font-width:bold; font-size:35px; text-align:center; font-weight:bold;">Pregled evidencije</caption>
           <tr style="background-color: #1a909e !important; font-weight: bold ; color: white !important;" align="center"; >
            <td>ID</td>
            <td>Ime studenta</td>
            <td>Prezime studenta</td>
            <td>Br. Indeksa</td>
            <td>Predmet</td>                  
            <td>Kolokvijum Teorija</td>
            <td>Kolokvijum Zadaci</td>
            <td>Aktivnost</td>
            <td>Prisustvo</td>   
            <td>Seminarski rad</td>
            <td>Domaći rad</td>
            <td>∑ Predisp. Obaveza</td>
            <td id="heed">Obriši</td>
            <td id="heed1">Ažuriraj</td>   

      </tr>

<?php        
  $ViewQuery="SELECT * FROM evid_record";
  $Execute= mysqli_query($connection, $ViewQuery);
while($datarows=mysqli_fetch_array($Execute)){
      $id=$datarows['id'];
      $ime=$datarows['imes'];
      $prezime=$datarows['prezimes'];
      $indeksbr=$datarows['indeksbr'];
      $predmet=$datarows['predmet'];
      $teorija=$datarows['teorija'];
      $zadaci=$datarows['zadaci'];
      $akt=$datarows['akt'];
      $pris=$datarows['pris'];
      $semrad=$datarows['semrad'];
      $domrad=$datarows['domrad'];
      $ukupno=$datarows['ukupno'];
    ?>


   <tr align="center" style="background-color: white !important" > 
    <td><?php echo $id?></td>
    <td><?php echo $ime ?></td>
    <td><?php echo $prezime?></td>
    <td><?php echo $indeksbr?></td>
    <td><?php echo $predmet?></td>
    <td><?php echo $teorija?></td>
    <td><?php echo $zadaci?></td>
    <td><?php echo $akt?></td>
    <td><?php echo $pris?></td>
    <td><?php echo $semrad?></td>
    <td><?php echo $domrad?></td>
    <td><?php echo $ukupno?></td>

<!--   Delete.php?*Delete* pokazivac u brisipodatke.php tj preuzima radnju odavde isto i za azuriraj-->
       <td><a id="heed3" href='brisistudente.php?Delete=<?php echo $id;?>'class='btn btn-danger'> Obriši <i class='fa fa-remove'aria-hidden='true' style="text-align:right"></i></a></td>  
       <td><a id="heed4" href='azurirajstudente.php?Update=<?php echo $id;?>'class='btn btn-success'> Ažuriraj <i class='fa fa-remove'aria-hidden='true' style="text-align:right"></i></a></td>
   </tr> 
<?php } ?>
</table>

<h2 style="text-align:center; color: #ed0404; font-size: 1.4em; font-weight: bold;" class="Sucsess"><?php echo @$_GET['Deleted']; ?></h2>
<h2 style="text-align:center; color: #ed0404; font-size: 1.4em; font-weight: bold;" class="Sucsess"><?php echo @$_GET['Updated']; ?></h2>

</body>
</html>

I need another table where user is going to input 'indeksbr'(id) and 'predmet'(subject - since my project is exam records of the students) and on submit they should get a filtered table with only the data relevant to/about them.

This is my code so far for filtered table, but I have no results in over 3 hours already..

<?php include("konekcija.php");?>    
<?php
    global $connection;
?>
<html>
<head>
    <meta charset="UTF-8">
    <title align="center">Prikaz evidencije</title>
    <?php include("studhome.php"); ?>

  <!--<div align="center" id="centar">
<input type="button" value="Štampaj evidenciju" class="btn btn-primary" onClick="document.location.href='print.php'" style="font-weight:bold;" /> 
</div>-->
<body>

   <table width="1000" border="3" align="center" style="width:80%">
       <caption style="text-align:center; font-width:bold; font-size:35px; text-align:center; font-weight:bold;">Pregled evidencije</caption>
           <tr style="background-color: #1a909e !important; font-weight: bold ; color: white !important;" align="center"; >
            <td>ID</td>
            <td>Ime studenta</td>
            <td>Prezime studenta</td>
            <td>Br. Indeksa</td>
            <td>Predmet</td>                  
            <td>Kolokvijum Teorija</td>
            <td>Kolokvijum Zadaci</td>
            <td>Aktivnost</td>
            <td>Prisustvo</td>   
            <td>Seminarski rad</td>
            <td>Domaći rad</td>
            <td>∑ Predisp. Obaveza</td>
            <!--<td id="heed">Obriši</td>
            <td id="heed1">Ažuriraj</td>-->   

      </tr>

<?php    
      if(isset($_POST['submit'])){

  $ViewQuery="SELECT * FROM evid_record WHERE (indeksbr = '$indeksbr' AND predmet = '$predmet')";
  $Execute= mysqli_query($connection, $ViewQuery);
while($datarows=mysqli_fetch_array($Execute)){
      $id=$datarows['id'];
      $ime=$datarows['imes'];
      $prezime=$datarows['prezimes'];
      $indeksbr=$datarows['indeksbr'];
      $predmet=$datarows['predmet'];
      $teorija=$datarows['teorija'];
      $zadaci=$datarows['zadaci'];
      $akt=$datarows['akt'];
      $pris=$datarows['pris'];
      $semrad=$datarows['semrad'];
      $domrad=$datarows['domrad'];
      $ukupno=$datarows['ukupno'];
    ?>


   <tr align="center" style="background-color: white !important" > 
    <td><?php echo $id?></td>
    <td><?php echo $ime ?></td>
    <td><?php echo $prezime?></td>
    <td><?php echo $indeksbr?></td>
    <td><?php echo $predmet?></td>
    <td><?php echo $teorija?></td>
    <td><?php echo $zadaci?></td>
    <td><?php echo $akt?></td>
    <td><?php echo $pris?></td>
    <td><?php echo $semrad?></td>
    <td><?php echo $domrad?></td>
    <td><?php echo $ukupno?></td>

<!--   Delete.php?*Delete* pokazivac u brisipodatke.php tj preuzima radnju odavde isto i za azuriraj-->

   </tr> 
<?php } ?>
</table>



</body>
</html>

And here's another .php where i have input fields for filtered table :

<?php include("konekcija.php");?>
<!doctype html>
<html lang=''>
<head>
   <meta charset='utf-8'>
   <meta http-equiv="X-UA-Compatible" content="IE=edge">
   <meta name="viewport" content="width=device-width, initial-scale=1">
   <link rel="stylesheet" href="styles.css">
     <script src="script.js"></script>
   <title>EPO - sistem</title>
    <!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<link rel="stylesheet" href="custom.css">
</head>

<link rel="stylesheet" href="styles.css">
<body>
<nav class="navbar" style="background-color:#1a909e;">

    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span> 
      </button>
      <a class="navbar-brand heads" href="#">EPO - SISTEM</a>
    </div>
    <div class="collapse navbar-collapse" id="myNavbar">
      <ul class="nav navbar-nav navbar-right">
        <li><a href="studhome.php" style="color:white;"><span class="glyphicon glyphicon-hand-right" style="color:white;"></span> <?php echo $_SESSION['sime']; ?> <?php echo $_SESSION['sprezime']; ?></a></li>

        <li><a href="studview.php" style="color:white;"><span class="glyphicon glyphicon-inbox" style="color:white !important;"></span> Prikaz evidencije</a></li>
        <!--<li><a href="print.php" style="color:white;"><span class="glyphicon glyphicon-print" style="color:white !important;"></span> Stampaj evidenciju</a></li>-->
        <li><a href="logout.php" style="color:white;"><span class="glyphicon glyphicon-log-out" style="color:white;"></span> LogOut</a></li>
      </ul>
    </div>

  <!--<li class="dash"><a href="#"><?php echo $_SESSION['semail']; ?></a></li>-->
    <div class="container-fluid">

</nav>

<div align="center" id="centar">
<div class="col-md-12">
   <div class="col-md-12">
                    <span class="FieldInfo">Broj indeksa: </span><br><input type="text" name="indeksbr" value=""><br>
                   </div>
    <span class="FieldInfo">Predmet: <br>
                    <select name="predmet" id="skraceno" style="width:187px; height:28px;">
                             <option>Izaberite..</option>
                              <option value="
                              <?php   
                                $ViewQuery="SELECT epredmet FROM evidall";
                                $Execute= mysqli_query($connection, $ViewQuery) or die(mysqli_error());
                                          while($datarows=mysqli_fetch_array($Execute)){
                                                $predmet= $datarows['predmet'];
                                                echo "<option value=\"".$datarows['epredmet']."\">" . $datarows['epredmet'] . "</option>";
    }

                                             ?>" ></option>
                              <br></select><br>
        </div>

</div>
<div align="center" id="centar">
<div class="col-md-12">
<input type="submit" name="submit" id="submit" value="Učitaj" class="form-control" style="height:42px; width:250px">
</div>
</div>
<div id="typed_text" class="row sub_msg" style="text-align:center;"></div>


<script src="typed.js"></script>
<div class="footer">
    <p id="fut">All rights reserved, Nikola Mandic ©</p>
    </div>
</body>
Answer 1

When you query "SELECT * FROM evid_record WHERE (indeksbr = '$indeksbr' AND predmet = '$predmet')"; there's no clue before of what are $indeksbr & $predmet variables.

I think you meant $_POST['indeksbr'] and $_POST['predmet'] ; If those variables are the data sent by your form.

READ ALSO
Why I can&#39;t change html format to php format

Why I can't change html format to php format

I got admin panel template from Creative TIM and I want to programing it from scratch but I can't write PHP commands inside HTML so I tried change it from dashboardcomponent

16
Find all audio files recursively and play them at random

Find all audio files recursively and play them at random

What would be a method that can find all audio files and play them at random

45
PHP form value results in array

PHP form value results in array

I have a PHP form that once it's filled it sends results back to my email as acsv file

15
Program runs but doesn&#39;t round corners

Program runs but doesn't round corners

I have the following:

24