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... Link to comment https://forums.phpfreaks.com/topic/18343-print-first-table-row-in-bold/ 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] Link to comment https://forums.phpfreaks.com/topic/18343-print-first-table-row-in-bold/#findComment-78870 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. Link to comment https://forums.phpfreaks.com/topic/18343-print-first-table-row-in-bold/#findComment-78871 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 Link to comment https://forums.phpfreaks.com/topic/18343-print-first-table-row-in-bold/#findComment-78891 Share on other sites More sharing options...
jcbarr Posted August 22, 2006 Author Share Posted August 22, 2006 **SOLVED**Thanks fellas. Link to comment https://forums.phpfreaks.com/topic/18343-print-first-table-row-in-bold/#findComment-78894 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.