Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
CREATE TABLE avatari (avatarName VARCHAR(255));
INSERT INTO avatari VALUES
('robert.smith@hg.osgrid.org:80'),
('foo@bar.org:80'),
('example@example.com:80');
<?php
$dbconnect = &$mysqli;
$sql = <<<SQL
SELECT SUBSTR(avatarName, INSTR(avatarName, '@') + 1) host
FROM avatari
ORDER BY avatarName
SQL;
echo '<table border="1">';
foreach (mysqli_query($dbconnect, $sql) as ['host' => $host]) {
echo "\n\t<tr><td>$host</td></tr>";
}