A
A
Alex Lav2020-05-03 01:08:06
PHP
Alex Lav, 2020-05-03 01:08:06

How to set css style to an element with class="server" after getting result from PHP script?

Hello, tell me to set the style for the element . If after the PHP script execution we get the value "0" without quotes. The php code itself"display: none;"
<tr class="server"">test123</tr>

<?php

require_once("protocol.php");

$output = '';

$servers = array(
array(
    "protocol" => "source",
    "ip" => "127.0.0.1",
    "port" => 12871,
  "qport" => 12881
  )
);

foreach($servers as $server) 
{

$data = lgsl_query_live($server['protocol'], $server['ip'], $server['port'], $server['qport'], $server['port'], 'spe');

$players_list = implode(", ",array_map(function($a) { return $a['name']; }, $data['p']));
    
$output = <<<HTML
    {$data['s']['playersmax']}
HTML;

echo $output;
}
  
?>


If we get any other value, then there is no need to hide the element with class="server".
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kashcheev, 2020-05-03
@kashcheev

1. https://overcoder.net/q/347798/%D0%B8%D0%B7%D0%BC%... - so-so.
2. Finding and replacing a class with php. How to implement? - why not an option?
3. Insert via echo directly into the body, by type:

if ($output == 0) {
    echo "<style> server {display: none} </style>";
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question