PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table members ( FName varchar(64), LName varchar(64) ); insert into members values ('Morgan', 'Freeman'), ('Robin', 'Williams'), ('Betty', 'White'), ('Sean', 'Connery'), ('Denzel', 'Washington'); select CONCAT(RPAD(FName, 64, ' '),' ',LName) as Full_Name from members
Copy Clear
Copy Format Clear
<?php $query = "SELECT MAX(LENGTH(FName)) as max_name from members;"; $stmt = $pdo->prepare($query); $stmt->execute(); $max_name_length = $stmt->fetchColumn(); $query = "SELECT FName, LName from members;"; $stmt = $pdo->prepare($query); $stmt->execute(); $members = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach($members as $member) { echo str_pad($member['FName'], $max_name_length + 2) . $member['LName'] . PHP_EOL; }
Show:  
Copy Clear