One of the first database outputs and i'm pretty much stuck. I want to add different classes to an array of information. The array has categories and that will be the leading value to add the class to. The code i'm using so far is:
<?php
$sql = "SELECT name,title,content,date,category FROM pinboard";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<article class='pin'><h2 class='pintitle'>".$row["title"]."</h2><p class='pincontent'>".$row["content"]."</p><div class='pininfo'><p class='pinname'>".$row["name"]."</p><p class='pindate'>".$row["date"]."</p></div></article>";
if($row['category'] = 2){
$('.pin').addClass("pin-message");
}
else if($row['category'] = 1){
$('.pin').addClass("pin-photo");
}
else if($row['category'] = 3){
$('.pin').addClass("pin-event");
}
}
} else {
echo "0 results";
}
?>
The if($row[category'] = 2){
line gives this result when it's displayed:
Parse error: syntax error, unexpected '(', expecting variable (T_VARIABLE) or '$' in C:\wamp\www....\index.php on line ..
I'm probably not identifying the problem correctly but I'm hoping you guys could help me further.