PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE `tokens` ( `id` int, `ticker` varchar(64), `symbol` varchar(64), `price` float, `f_long` varchar(64), `f_short` varchar(64), `s_long` varchar(64), `s_short` varchar(64), `volume_5m` varchar(64), `volatility` float ); INSERT INTO `tokens` (`id`, `ticker`, `symbol`, `price`, `f_long`, `f_short`, `s_long`, `s_short`, `volume_5m`, `volatility`) VALUES (22, 'AXS', 'AXSUSDT', 29.74, '30.38000;6957;211353;2.2;08.05.2022 16:46:33;0', '29.00000;11837;343273;2.4;08.05.2022 16:34:34;0', '29.96000000;3685.37000000;110413;0.8;08.05.2022 16:47:39;0', '29.54000000;4505.01000000;133077;0.6;08.05.2022 16:44:33;0', '7834.94000000;233522.11020000', 0.57), (23, 'BAKE', 'BAKEUSDT', 0.5101, '', '', '', '', '40769.10000000;20803.43380000', 0.39), (24, 'BAL', 'BALUSDT', 12.725, '', '', '', '', '253.24000000;3219.11980000', 0.16), (25, 'BAND', 'BANDUSDT', 2.7832, '', '', '', '', '857.90000000;2390.26030000', 0.32), (26, 'BAT', 'BATUSDT', 0.5528, '', '', '', '0.54920000;299874.00000000;164690;0.5;08.05.2022 16:46:42;0', '20586.00000000;11396.99290000', 0.31);
Copy Clear
Copy Format Clear
<?php // Run query using mysqli $result = $mysqli->query("SELECT * FROM `tokens` ORDER BY `f_long` DESC, `f_short` DESC, `s_long` DESC, `s_short` DESC, `id`"); $tokens = $result->fetch_all(MYSQLI_ASSOC); print_r($tokens); usort($tokens, function ($a, $b) { $a = explode(';',$a['f_long']); $b = explode(';',$b['f_long']); if ($a[3] == $b[3]) { return 0; } return $a[3] < $b[3]?-1:1; });
Show:  
Copy Clear