Hello, I have a question. Suppose there is a base with columns
An example of blocks (they contain the request code) and all blocks are separate from each other.
id - name - type - text
and a few queries to the database:
<?php require "подключение"; $sql = "SELECT name, id FROM таблица WHERE type='такой-то'"; $result = $conn->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { echo "".$row['id']."";}} else { echo "пусто"; } $conn->close(); ?> and such zaprov on the page about ten pieces ...
How can these queries be combined into one query ?
Here is an example of how the code looks on the page now (three blocks):
блок1 <?php require "подключение"; $sql = "SELECT name, id FROM таблица WHERE type='1'"; $result = $conn->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { echo "".$row['id']."";}} else { echo "пусто"; } $conn->close(); ?> блок2 <?php require "подключение"; $sql = "SELECT name, id FROM таблица WHERE type='2'"; $result = $conn->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { echo "".$row['id']."";}} else { echo "пусто"; } $conn->close(); ?> блок3 <?php require "подключение"; $sql = "SELECT name, id FROM таблица WHERE type='3'"; $result = $conn->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { echo "".$row['id']."";}} else { echo "пусто"; } $conn->close(); ?> 
WHERE type in ('1','2','3')- splash58typelikei++and substitute it into the query. - Dan the HatSELECT name, id, type FROM таблица WHERE type in ('1','2','3'). Next, using php, form three arrays (in thetypecolumn) and stuff the data into your blocks - ArchDemon