Hello, by Get'u I give digital values, for example site.php? Id = 271, on the map page there is a table with columns, and a special css style is added to column 271, but how to do so site.php? Id = 271,255,260 to three aydishnikam added css styles, I think the function is needed here explode (), but how to bring it to the end to mind?
the style itself is added through such a rule if ($ id == "271") {echo "class = 'select'";}

  • It seems that if you transfer as site.php? Id = 271 & id = 255 & id = 260, then \ $ _ GET ['id'] will return an array of values. Maybe I'm wrong, and php doesn't work that way. - Valeriy Karchov
  • 2
    You are mistaken, but it will work if you transmit ... php? Id [] = 271 & id [] = 255 & id [] = 260 - Sh4dow
  • Thanks for the info, I will know. - Valeriy Karchov

3 answers 3

$ids = explode(',',$_GET[id]); $ids = array_flip($ids); //ЦИКЛ_РИСОВАНИЯ_ТАБЛИЦЫ if(isset($ids[$column_id])){ $cssclass = ' class="myclass"'; }else{ $cssclass = ''; } $out .= sprintf('<td%s>%s</td>',$class, $SOME_CONTENT); //КОНЕЦ_ЦИКЛА return $out; 
  • I have a table built in a special way, such as drawing a building)) and the cycle will output it incorrectly ) - dogmar
  • Well ... you can use pens to check the desired column / row. O_o Although what this special, <s> street magic </ s> table, which you can’t derive in a cycle, is hard for me to imagine. - knes
  • thank you) something took from your code and everything works - dogmar

Probably, you "highlight" the lines in which objects are in some special state for you. Why not store the flag of this state in the database? You do feel that passing through GET for example 100 values ​​is not an option at all?

  • a maximum of 3 values ​​are transmitted through the het, in my cases) and can no longer be - dogmar
  • Then explode (',', $ _ GET [id]); solve the problem with a bang. - Vitaly Kustov
 $rows = explode(',', $_GET['id']); 

Now $rows array of values ​​you need. So that you can be helped with the output in the views, please post a piece of your code responsible for the output. To check if there is such a value, use the in_array() function.

  • and how now to put a check whether there is in the array 271 or not? I laid out the question - dogmar
  • Like that) $ est271 = in_array (271, $ rows); - Sh4dow
  • in_array is slow too. Do not teach a person bad: to flip and look for a key goes out many times faster. Accidentally discovered when he counted the number of words in "War and Peace." - knes
  • And you can read more? With the if else construct, please) If there is an array, then set the class class = 'select', if not, then no) - dogmar