the user selects values ​​in the filter and the result is output for the corresponding values, but the values ​​do not always coincide with the result and currently need to be implemented, if the value does not match, then it gives out> Unfortunately, nothing was found for this query

There is this kind of get request

/?filter_ширина=68&filter_высота=40&filter_диаметр=&filter_бренд=&filter_cезон=&filter_тип= 

In which there is no product to display text

"Sorry, nothing was found for this query"

And there are several such requests.

  • If this is a get request, then parse it on the server; if it does not find any products, return a string that was not found. Take it and display where it is convenient for you using javascript . And so it’s not clear from your question what you’ve got and what you’ve already done to make it happen. - Moonvvell

1 answer 1

It depends on what you are interested in?

PHP:

 if (!isset($_GET['tovar']) || empty($_GET['tovar'])) { redirect('404'); // пользователькая функция } 

Js:

 function parse(val) { var result = "Not found", tmp = []; location.search .substr(1) .split("&") .forEach(function (item) { tmp = item.split("="); if (tmp[0] === val) result = decodeURIComponent(tmp[1]); }); return result; } 

Where in val the necessary parameter is transferred, depending on the result, direct where you want window.location.href = "http://ru.stackoverflow.com"; but it is better to do it on the server side.

  • Could describe this creak, I don’t quite understand where it is - Ivan Kling
  • What exactly is @IvanKling, and back to the first question, what exactly do you need to do, do you need to implement a check on the client side or on the server side, do you have to process something? - Shadow33
  • On the client side, it processes get requests, the user chooses values ​​in the filter and gives the result for the corresponding values, but the values ​​do not always match the result and currently need to be implemented, if the value does not match, then it gives out> Unfortunately, nothing was found for this query - Ivan Kling