mysql_fetch_array() & if(THIS IS FIRST ROW) {

Discussion in 'PHP' started by dracula51, Mar 8, 2012.

  1. #1
    hi,
    heres my script..

    $result = mysql_query("SELECT * FROM `user` order by `credit` LIMIT 5");
    
    while($row = mysql_fetch_array($result)){
       if (THIS IS THE FIRST RESULT)
       echo "<b>".$row['name']."</b>";
    
       else
       echo $row['name'];
    }
    PHP:
    so my whole point is, i want the first result Highlighted & rest will be normal...

    i dont know tht if( ?? any other way??

    help plz
     
    dracula51, Mar 8, 2012 IP
  2. prabhunimish

    prabhunimish Member

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    46
    #2
    i dint use much brains on this, so this may not be the best approach but here goes the code :

    
    $result = mysql_query("SELECT * FROM `user` order by `credit` LIMIT 5");
    $count = 0;
    while($row = mysql_fetch_array($result)){
    	$count++;
    	if ($count == 1)
    		echo "<b>".$row['name']."</b>";
    	else
    		echo $row['name'];
    }
    
    Code (markup):
     
    prabhunimish, Mar 8, 2012 IP
  3. dracula51

    dracula51 Peon

    Messages:
    146
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    damn...sometimes we dont think straight :( :(

    but thanks a lot mate :)
     
    dracula51, Mar 8, 2012 IP