PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE my_table ( id INT AUTO_INCREMENT, state VARCHAR(100), link VARCHAR(100), PRIMARY KEY (id) ); INSERT INTO my_table(id, state, link) VALUES (1, 'Alabama', 'auburn.alabama.com'), (2, 'Alabama', 'bham.alabama.com'), (3, 'Alabama', 'dothan.alabama.com');
Copy Clear
Copy Format Clear
<?php // $mysqli is already declared as a working database connection by this sandbox $r = []; foreach ($mysqli->query('SELECT * FROM my_table') as ['link' => $link, 'state' => $result[$link]]); //var_export($result); echo $r['auburn.alabama.com'];
Show:  
Copy Clear