PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE cars ( id int, cars text ); INSERT INTO cars VALUES (1, 'Toyota, Lexus, Benz');
Copy Clear
Copy Format Clear
<?php $query = "SELECT cars FROM cars WHERE id = 1;"; $result = $pdo->prepare($query); $result->execute(); $row = $result->fetch(PDO::FETCH_ASSOC); $cars = explode(',', $row['cars']); foreach($cars as $car) { $car = trim($car); echo "<option value=\"$car\">$car</option>" . PHP_EOL; }
Show:  
Copy Clear