im trying to change query depending on what user has selected. In my case there are displayed two photos with labels pulled from data base. And depending which image is clicked i want that label to be used in query who will display items associated in database with that label. I tried using global variables, but it i didn't work for me. I cant figure out how to insert data into query after user clicked something
There is code fragment where i pull photos with labels from database, and depending on which i select i want "$modeliai_results['Modelis']" (vehicle model label) to be sent and used in another query below
<div class="eile">
    <?php
    echo '
    <a href="standartiniskatalogas.php?page=kategorijos"/>
    <img src="data:image/jpeg;base64,'.base64_encode( $modeliai_results['Nuotrauka'] ).'"/>
    <div class="description">'.$modeliai_results['Marke'].' '.$modeliai_results['Modelis'].'
    </div></a>';
?>
Page from second image which should execute query depending on selection from previous page:
<?php
    $kategorijos_sql="SELECT * FROM kategorijos (HERE SHOULD BE ADDED: "WHERE Modelis='MODEL NAME WHICH WAS SELECTED WHEN PRESSED ON IMAGE'";
    $kategorijos_query=mysqli_query($dbconnect, $kategorijos_sql);
    $kategorijos_results=mysqli_fetch_assoc($kategorijos_query);
do{
    echo '
    <div class="eile2">
    <a href="isore/isore.html">
    <img src="data:image/jpeg;base64,'.base64_encode( $kategorijos_results['Nuotrauka'] ).'"/>
    <div class="description">'.$kategorijos_results['Kategorija'].'</div>
    </a></div>'; /* uzdaro echo*/
    }
    while ($kategorijos_results=mysqli_fetch_assoc($kategorijos_query))
     ?>
ps. Im not using any extra tools or libraries.
