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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.