Jump to content

Recommended Posts

Just add a counter to your while loop:

 

<?php

$i = 1;

while($row = mysql_fetch_array($gettopfour))

    if($i = 3) {
      echo "something before the 3rd row";
    }
    
    echo $row['something'];

   $i++;

?>

Yes it looks like I did, but I actually meant = and not <= at the time... but now I can see I misunderstood him.

 

I thought of "before the 3rd row to echo something" as "to echo something between the 2nd and 3rd row" - but of course (maybe) he want to highlight the 3 highest scores or something like that.

Yes it looks like I did, but I actually meant = and not <= at the time... but now I can see I misunderstood him.

A single = would have been even more wrong in this context.

 

it puts it on everyline before the 4th one now

<?php
  $i = 0;
  while($row = mysql_fetch_assoc($result)){
    if($i == 4){
      // Rows 1 - 3
    }
    $i++;
  }
?>

 

Are you just blindly copying and pasting code or are you making any attempt to understand what's happening here?

Yes, I forgot a =, it should have been ==.

 

If you mean / meant between 2nd and 3rd row you can use something like my first code, just correct the = to ==

 


<?php

$i = 1;

while($row = mysql_fetch_array($gettopfour))

    if($i == 3) {
      echo 'something before the 3rd row';
    }
    
    echo $row['something'];

   $i++;

?>

 

This will echo 'something before the 3rd row' before the third row...

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.