Reputation: 69
$query = $this->db->query('SELECT * FROM feeder_categories');
$result = $query->result();
$cat = '';
print $category;
foreach ($result as $row) {
$selected = '';
if($row->Category_Term=$category){$selected = 'selected="1"'; print $row->Category_Term;}
$cat .= "<option value='" . $row->Category_Term . "' ".$selected.">" . $row->Category_Label .
"</option>";
}
The database looks like this (According to phpMyAdmin)
id Category_Term Category_Label
1 Film Film & Animation
2 Autos Autos & Vehicles
3 Music Music
4 Animals Pets & Animals
5 Sports Sports
6 Travel Travel & Events
7 Shortmov Short Movies
8 Videoblog Videoblogging
Yet the script says that $row->Category_Term is sports every single time it cycles through the list. Its returning $row->Category_Label properly though.
This was working perfectly fine on an Xampp dev server. It was then moved to a nginx vps for release, and this stupid error showed up.
Any help?
Upvotes: 1
Views: 75
Reputation: 224922
You're assigning to the category here instead of comparing:
if($row->Category_Term=$category)
Equality is done in PHP with a double-equals, so change it to:
if($row->Category_Term == $category)
Upvotes: 1