C
C
Chesterfield252021-06-10 16:42:06
PHP
Chesterfield25, 2021-06-10 16:42:06

How to filter content?

I can't figure out how to filter the material?

Sample from the database

$sql = $pdo->prepare("SELECT xf_list.id as id_f, xf_list.title as title_f, xf_list.url as url_f, xf_category.id as id_c, xf_category.title as title_c, xf_type.title as title_t, xf_type.url as url_t FROM `xf_list` LEFT JOIN `xf_category` ON `xf_list` . `category_id`=`xf_category` . `id` LEFT JOIN `xf_type` ON `xf_list` . `type_id`=`xf_type` . `id`");
$sql->execute();
$result = $sql->fetchAll(PDO::FETCH_OBJ);


Output per page

<table class="table shadow ">
    <thead class="thead-dark">
      <tr>
        <th>#</th>
        <th>Name</th>
        <th>Currency</th>
        <th>MicroWallet</th>
        <th>Visit</th>
      </tr>

<?php foreach ($result as $value) { ?>
<tr>
<td><?=$value->id_f ?></td>
<td><a href="<?=$value->url_f ?>" target="_blank"><?=$value->title_f ?></a></td>
<td><?=$value->title_c ?></td>
<td><a href="<?=$value->url_t ?>" target="_blank"><?=$value->title_t ?></a></td>
<td><a class="btn btn-primary" href="<?=$value->url_f ?>" target="_blank" role="button">View</a></td>
<?php } ?>
</tr>
  </thead>
  </table>


I need the ability to filter by

<?=$value->title_t ?>

and by

<?=$value->title_c ?>

well, or at least by the last one!

What do I get on the page

60c21696a546e075067552.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
ThunderCat, 2021-06-10
@ThunderCat

Pass data for the filter in get parameters, process them on the backend and add the appropriate conditions to the request.
PS: Why, I wonder, do you prepair if you don't use prepared expressions??? How about USE prepared expressions?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question