How to display first record in bold

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dr. zoidberg

    How to display first record in bold

    Hello,

    I'm pulling news titles from MySQL. How Can I display first record in
    bold (different than other ones). What is the best way to do that. Is
    there some 'magic' query or PHP function.

    *First Headline*
    Second Headline
    Third Headline

    TNX

  • Andreas Paasch

    #2
    Re: How to display first record in bold

    dr. zoidberg wrote:
    [color=blue]
    > Hello,
    >
    > I'm pulling news titles from MySQL. How Can I display first record in
    > bold (different than other ones). What is the best way to do that. Is
    > there some 'magic' query or PHP function.
    >
    > *First Headline*
    > Second Headline
    > Third Headline
    >
    > TNX[/color]

    I would look into mysql_num_rows == 1 ... if your select statement is made
    orderly.
    If the value is one, then print in bold ... else don't.

    /Andreas
    --
    Registeret Linux user #292411

    Comment

    • Andy Hassall

      #3
      Re: How to display first record in bold

      On Sat, 15 Nov 2003 01:28:27 +0100, "dr. zoidberg" <someone@exampl e.wrong>
      wrote:
      [color=blue]
      >I'm pulling news titles from MySQL. How Can I display first record in
      >bold (different than other ones). What is the best way to do that. Is
      >there some 'magic' query or PHP function.
      >
      >*First Headline*
      > Second Headline
      > Third Headline[/color]

      Just use a simple flag.

      $first = true;
      while ($row = mysql_fetch_arr ay()) {
      if ($first) {
      // bold
      $first = false;
      } else {
      // normal
      }
      }

      --
      Andy Hassall (andy@andyh.co. uk) icq(5747695) (http://www.andyh.co.uk)
      Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)

      Comment

      • Geoff Berrow

        #4
        Re: How to display first record in bold

        I noticed that Message-ID: <4hvarvkjqbk0al rdvnfau55m4muhf m34hk@4ax.com>
        from Andy Hassall contained the following:
        [color=blue]
        > Just use a simple flag.
        >
        >$first = true;
        >while ($row = mysql_fetch_arr ay()) {
        > if ($first) {
        > // bold
        > $first = false;
        > } else {
        > // normal
        > }
        >}[/color]
        Calling the function does that automatically

        $row = mysql_fetch_arr ay()
        //print the row in bold
        while ($row = mysql_fetch_arr ay()) {
        //print the other rows normally
        }

        --
        Geoff Berrow (put thecat out to email)
        It's only Usenet, no one dies.
        My opinions, not the committee's, mine.
        Simple RFDs http://www.ckdog.co.uk/rfdmaker/

        Comment

        • nariman amiri

          #5
          Re: How to display first record in bold

          Andreas Paasch wrote:
          [color=blue]
          > dr. zoidberg wrote:[/color]
          [color=blue][color=green]
          >> Hello,
          >>
          >> I'm pulling news titles from MySQL. How Can I display first record
          >> in
          >> bold (different than other ones). What is the best way to do that.
          >> Is
          >> there some 'magic' query or PHP function.
          >>
          >> *First Headline*
          >> Second Headline
          >> Third Headline
          >>
          >> TNX[/color][/color]
          [color=blue]
          > I would look into mysql_num_rows == 1 ... if your select statement is
          > made
          > orderly.
          > If the value is one, then print in bold ... else don't.[/color]
          [color=blue]
          > /Andreas[/color]


          As far as I know there is no single SQL line that can solve your problem.
          you need to check the pointer location, and the best way will be something
          like this:

          $query_headline = mysql_query ("SELECT headline FROM headlines") or die
          ("Query failed!");
          $first_row = true;
          while ($row=mysql_fet ch_array($query _headline)){
          if ($first_row)
          {
          echo "<b>".$row['topicName']."</b><br />";
          $first_row = false;
          } else
          {
          echo $row['topicName']."<br />";
          }
          }

          Hope it helps...

          ##-----------------------------------------------#
          Article posted from PHP Freaks NewsGroup

          Get Addicted: comp.lang.ph
          ##-----------------------------------------------##

          Comment

          Working...