Jump to content

Print first table row in bold...


jcbarr

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...
Link to comment
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]
Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.