P
P
Pavel2018-05-23 16:20:55
PHP
Pavel, 2018-05-23 16:20:55

How to show data from different mysql tables?

New to php, please help.
As when clicking on a certain filter link, in the directory in the mysql query, the table changed. For example, you click on Intel core i9, does the cpu-i9 table come out?
I know that it is possible somehow through the GET parameter. Need at least an example

<h5>Фильтр</h5> 
<div class="list-group">
  <a href="#" class="list-group-item list-group-item-action">Показать все</a>
  <a href="#" class="list-group-item list-group-item-action">Intel Core i9</a>
  <a href="#" class="list-group-item list-group-item-action">Intel Core i7</a>
  <a href="#" class="list-group-item list-group-item-action">Intel Core i5</a>
  <a href="#" class="list-group-item list-group-item-action">Intel Core i3</a>
  <a href="#" class="list-group-item list-group-item-action">Intel Core Pentium</a>
</div>

<h5>Каталог товаров</h5>

      <?php 
      $sql = $link->query("SELECT * FROM `cpu-i7`");
      $link->close;

      while($result = $sql->fetch_assoc()): ?>
        
<div class="media" style="background-color: ">
  <img class="mr-2" width="140px" src="<?=$result['img']?>">
  <div class="media-body">
    <h5 class="mt-0"><?=$result['title']?></h5>
  <p><?=$result['text']?></p>
  <h5><?=$result['price']?></h5>
  </div>
</div>

<? endwhile ?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2018-05-23
@sidiqi

<a href="?cpu=cpu-i7" class="list-group-item list-group-item-action">Intel Core i7</a>

This is the answer to the question, so to speak, but in general:
1) use TWIG as a template engine to trim view and MODEL
2) use PDO to write SQL in a human way
3) Create one table with all percents. and their characteristics, and make a choice
Understand all this, take Laravl, Symfony, and do

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question