jcbarr Posted August 22, 2006 Share Posted August 22, 2006 Okay here is the code...[code]<?php//Get UL C$sql="SELECT * FROM ballot WHERE POS='C' AND LEAGUE='UL' ORDER BY VOTES DESC LIMIT 2";$result=mysql_query($sql);//Create loop and print rowswhile($ulfbase=mysql_fetch_array($result)){ echo "<tr>"; echo "<td align=center>"; echo $ulfbase['NAME']; echo "</td><td align=center>"; echo $ulfbase['STAT']; echo "</td><td align=center>"; echo $ulfbase['VOTES']; echo "</td>"; echo "</tr>";}?>[/code]Now it only pulls two rows from the database, how do I make it print the text in the first table row in bold, while printing the second table row normal?Thanks in advance guys, I'm sure this is simple, I just can't think of how to do it right now... Quote Link to comment Share on other sites More sharing options...
Caesar Posted August 22, 2006 Share Posted August 22, 2006 I suspect you want to do something like this:[code]<?php//Get UL C$sql="SELECT * FROM ballot WHERE POS='C' AND LEAGUE='UL' ORDER BY VOTES DESC LIMIT 2";$result=mysql_query($sql);//Create loop and print rowswhile($ulfbase=mysql_fetch_array($result)){$countshit++;if($countshit == 3){$countshit = 1;}if($countshit == 1){$ulfbase['NAME'] = "<b>$ulfbase['NAME']</b>";}if($countshit == 2){$ulfbase['NAME'] = $ulfbase['NAME'];}echo"<tr><td align=center>$ulfbase['NAME']</td><td align=center>$ulfbase['STAT']</td><td align=center>$ulfbase['VOTES']</td></tr>";}?>[/code] Quote Link to comment Share on other sites More sharing options...
Caesar Posted August 22, 2006 Share Posted August 22, 2006 Test it though. :-) I'm at work and only threw that together. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted August 22, 2006 Share Posted August 22, 2006 If you just want to print the first line in bold and the rest normal, you can use a simple true/false flag:[code]<?php$firstflag = false; // has first row been printed?$sql="SELECT * FROM ballot WHERE POS='C' AND LEAGUE='UL' ORDER BY VOTES DESC LIMIT 2";$result=mysql_query($sql);//Create loop and print rowswhile($ulfbase=mysql_fetch_assoc($result)){ $style = (!$firstflag)?'style="font-weight:bold;text-align:center"':'style="text-align:center"'; // make the correct style echo "<tr>"; echo "<td $style>"; echo $ulfbase['NAME']; echo "</td><td $style>"; echo $ulfbase['STAT']; echo "</td><td $style>"; echo $ulfbase['VOTES']; echo "</td>"; echo "</tr>"; if (!$firstflag) $firstflag = true; // first line has been printed}?>[/code]Ken Quote Link to comment Share on other sites More sharing options...
jcbarr Posted August 22, 2006 Author Share Posted August 22, 2006 **SOLVED**Thanks fellas. 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.