Reputation: 11
I have a quick question, I'm not sure what I have done wrong in this part of the code but every time Type(NUM) equals the value of the if statement.
I've tried with 2 pieces of data
ID 1 = Type(NUM) 2
ID 2 = Type(NUM) 1
But it's only going to the first if statement and stopping.
Picture of this (https://i.sstatic.net/Of4B6.png)
The code is;
while($row = mysqli_fetch_assoc($result)){
if($row["Commit"]== "test"){
continue;
}
echo "<tr ID = \"cell\">";
if($row['Type(NUM)'] = 1){
echo '<td style="background-color:#ffab0a; font-weight:bold"> UPDATE</td>';
}
else if($row['Type(NUM)'] = 2){
echo '<td style="background-color:#00cc00; font-weight:bold">NEW </td>';
}
else if($row['Type(NUM)'] =3){
echo '<td style="background-color:#ff00ff; font-weight:bold"> FIX </td>';
}
else if($row['Type(NUM)'] =4 ){
echo '<td style="background-color:#cc0000; font-weight:bold"> REMOVE </td>';
}
echo "<td>".$row['ID']."</td>";
Upvotes: 0
Views: 30
Reputation: 206
you every time do the if you are making the $var to num use ' == ' instead of ' = '
Upvotes: 0
Reputation: 50
U must use $row['Type(NUM)'] == 2
not '='
while($row = mysqli_fetch_assoc($result)){
if($row["Commit"]== "test"){
continue;
}
echo "<tr ID = \"cell\">";
if($row['Type(NUM)'] == 1){
echo '<td style="background-color:#ffab0a; font-weight:bold"> UPDATE</td>';
}
else if($row['Type(NUM)'] == 2){
echo '<td style="background-color:#00cc00; font-weight:bold">NEW </td>';
}
else if($row['Type(NUM)'] ==3){
echo '<td style="background-color:#ff00ff; font-weight:bold"> FIX </td>';
}
else if($row['Type(NUM)'] ==4 ){
echo '<td style="background-color:#cc0000; font-weight:bold"> REMOVE </td>';
}
echo "<td>".$row['ID']."</td>";
Upvotes: 1