Answer the question
In order to leave comments, you need to log in
How to get data from database and insert it into PHP code?
Hello, help me sort the data from the ib DB and insert it into PHP
I have a database "base_mon" it has a table "base_post" in the table there is a column "xfields"
This column has data in the form:
ips|127.0.0.1||port|12871||query|12881|
From this data I need to get separately information 127.0.0.1
, separate 12871
and separate information 12881
(information is always different) and insert the received information into the PHP script:
<?php
require_once("protocol.php");
$output = '';
$servers = array(
array(
"protocol" => "source",
"ip" => "[xfvalue_ips]", //- здесь должна выводиться информация 127.0.0.1 из БД
"port" => [xfvalue_port], //- здесь должна выводится информация 12871 из БД
"qport" => [xfvalue_query] //- здесь должна выводится информация 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']['players']} / {$data['s']['playersmax']}
HTML;
echo $output;
}
?>
Answer the question
In order to leave comments, you need to log in
Этот код будет работать только если структура данных будет как в примере:
$string = 'ips|127.0.0.1||port|12871||query|12881|';
[, $ip, , , $port, , , $query] = explode('|', $string);
var_dump($ip);
var_dump($port);
var_dump($query);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question