benji87 Posted April 27, 2007 Share Posted April 27, 2007 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. Quote Link to comment Share on other sites More sharing options...
taith Posted April 27, 2007 Share Posted April 27, 2007 um... what type of loop? what are you expecting to get out? what do you have going in? Quote Link to comment Share on other sites More sharing options...
benji87 Posted April 27, 2007 Author Share Posted April 27, 2007 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. Quote Link to comment Share on other sites More sharing options...
taith Posted April 27, 2007 Share Posted April 27, 2007 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>"; } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.