1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

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 Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #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