You are comparing, not assigning:
if ($type == 1){
$type = "Bear";
}
You compare values with ==
or ===
.
You assign values with =
.
You could write less code to achieve the same result too, with a switch
statement, or just a bunch of if
s without the elseif
s.
if ($type == 1) $type = "Bear";
if ($type == 2) $type = "Cat";
if ($type == 3) $type = "Dog";
I would make a function for it, like this:
function get_species($type) {
switch ($type):
case 1: return 'Bear';
case 2: return 'Cat';
case 3: return 'Dog';
default: return 'Jeff Atwood';
endswitch;
}
$type = get_species($row['ttype']);