if ($row['active'] == 1) echo '<a href="prof?id=$id">'.htmlspecialchars($row['username']).'</a>'; else echo htmlspecialchars($row['username']);
Could I write this shorter and cleaner somehow?
if ($row['active'] == 1) echo '<a href="prof?id=$id">'.htmlspecialchars($row['username']).'</a>'; else echo htmlspecialchars($row['username']);
Could I write this shorter and cleaner somehow?
echo $row['active'] == 1 ? '<a href="prof?id=$id">'.htmlspecialchars($row['username']).'</a>' : htmlspecialchars($row['username']);
explained a little here http://www.addedbytes.com/php/ternary-conditionals/
I'm assuming you made a mistake putting the $id in a single quoted string, and meant for php to put the value of $id in its place in there.
$name=htmlspecialchars($row['username']);
if($row['active'] == 1) {
echo "<a href='prof?id=$id'>$name</a>";
} else {
echo $name;
}