Connecting Tech Pros Worldwide Help | Site Map

How to display first record in bold

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 01:08 AM
dr. zoidberg
Guest
 
Posts: n/a
Default 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


  #2  
Old July 17th, 2005, 01:08 AM
Andreas Paasch
Guest
 
Posts: n/a
Default 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
  #3  
Old July 17th, 2005, 01:08 AM
Andy Hassall
Guest
 
Posts: n/a
Default Re: How to display first record in bold

On Sat, 15 Nov 2003 01:28:27 +0100, "dr. zoidberg" <someone@example.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_array()) {
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)
  #4  
Old July 17th, 2005, 01:09 AM
Geoff Berrow
Guest
 
Posts: n/a
Default Re: How to display first record in bold

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

$row = mysql_fetch_array()
//print the row in bold
while ($row = mysql_fetch_array()) {
//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/
  #5  
Old July 17th, 2005, 11:30 AM
nariman amiri
Guest
 
Posts: n/a
Default 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_fetch_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
http://www.phpfreaks.com/newsgroup
Get Addicted: comp.lang.ph
##-----------------------------------------------##
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.