Jump to content

Loop


benji87

Recommended Posts

Hey guys, could someone please show me the best way to make this into a loop:

 

if ($sk > 0) {
echo "<td width=100 bgcolor=\"$row_colour\" class='navigation'><div align='centre'>Subject Knowledge</div></td>";
} else {
echo "";
}
if ($afl > 0) {
echo "<td width=100 bgcolor=\"$row_colour\" class='navigation'><div align='centre'>Assessment for learning</div></td>";
} else {
echo "";
}
if ($lst > 0) {
echo "<td width=100 bgcolor=\"$row_colour\" class='navigation'><div align='centre'>Learning style theories</div></td>";
} else {
echo "";
}

 

Im not sure how to do it as eah result is based on a different variable.

Link to comment
https://forums.phpfreaks.com/topic/48913-loop/
Share on other sites

Ok i want it to echo

 

<td width=100 bgcolor=\"$row_colour\" class='navigation'><div align='centre'>$VARIABLE</div></td>

 

WHILE

 

an array of results returned from a database = 1

 

So for every result returned from the query that = 1 echo the name of that result.

Link to comment
https://forums.phpfreaks.com/topic/48913-loop/#findComment-239711
Share on other sites

o...k...?

 

while($row=mysql_fecth_assoc($query)){
if($sk > 0){
  echo "<td width=100 bgcolor='$row[colour]' class='navigation'><div align='centre'>$row[VARIABLE]</div></td>";
}elseif($afl > 0){
  echo "<td width=100 bgcolor='$row[colour]' class='navigation'><div align='centre'>$row[VARIABLE]</div></td>";
}elseif($lst > 0){
  echo "<td width=100 bgcolor='$row[colour]' class='navigation'><div align='centre'>$row[VARIABLE]</div></td>";
}
}

Link to comment
https://forums.phpfreaks.com/topic/48913-loop/#findComment-239716
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.