Jump to content

Archived

This topic is now archived and is closed to further replies.

jcbarr

Print first table row in bold...

Recommended Posts

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 rows
while($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...

Share this post


Link to post
Share on other sites
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 rows
while($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]

Share this post


Link to post
Share on other sites
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 rows
while($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

Share this post


Link to post
Share on other sites

×

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.