Answer the question
In order to leave comments, you need to log in
How to check the correspondence between categories?
Hello, such a question. There are products on one site, they are located in categories / subcategories, I copy these products to my site using a parser, but I ran into such a problem. On a third-party site, categories of this type are "Children's World » Children's Shoes", "Children's World » Toys", i.e. category and sub-category. On my site, the categories are slightly different from these, and I have collected an array like 'category from a third-party site' => 'my category'. But the catch is that I need to somehow compare these categories in order to correctly enter products into the database. I'm trying to do so
foreach ($result as $s) {
foreach ($categories as $cat) {
if (key($categories) == $category){
echo current($cat);
}
}
}
Answer the question
In order to leave comments, you need to log in
Why don't you just do it?
if (isset($categories[$category]) {
echo $category;
}
$sql = mysqli_query($db_connect, "SELECT `fk_i_category_id`, `s_name` FROM `oc_t_category_description` WHERE 1");
$result = mysqli_fetch_all($sql);
echo $category . "<br>";
foreach ($result as $s) {
foreach ($categories as $cat) {
if (key($categories) == $category){
echo current($cat);
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question