W
W
wagwandude2016-12-25 12:09:06
PHP
wagwandude, 2016-12-25 12:09:06

How to remove from a table by condition?

Hello.

// получаю id категорий через запятую из таблицы
$connect = $db->query("SELECT * FROM `o_post` WHERE `id` = '$an_id'");
$get = $db->get_row($connect);

// создаю массив, чтобы работать с ним
$categories = explode(',', $get['category']);

How to loop through the resulting array and display from the table a maximum of 5 records whose post id is equal to the one sent ($an_id) and in the category column there are at least two matches in the array (it should be taken into account that categories are stored in the table separated by commas )?
Cycles are very tight..
Thanks in advance for your help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2016-12-25
@webinar

category table are stored separated by commas

This is a joke? What for? How to work with it?
there is a LIMIT for this
And what in php is given to you easier than cycles? Just wondering what could be easier? echo?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question