Connecting Tech Pros Worldwide Help | Site Map

How to display first record in bold

  #1  
Old July 17th, 2005, 02:08 AM
dr. zoidberg
Guest
 
Posts: n/a
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, 02:08 AM
Andreas Paasch
Guest
 
Posts: n/a

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, 02:08 AM
Andy Hassall
Guest
 
Posts: n/a

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, 02:09 AM
Geoff Berrow
Guest
 
Posts: n/a

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, 12:30 PM
nariman amiri
Guest
 
Posts: n/a

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
##-----------------------------------------------##
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
strange update problem .net sirdavethebrave answers 2 November 3rd, 2008 07:40 PM
how to retrieve records submmited on a form kev answers 13 December 8th, 2006 04:05 AM
DetailsView ASP Control and an empty field not an empty record. ButlerDJIAM answers 0 November 9th, 2006 06:25 PM
Script to collapse a list Alvaro G Vicario answers 4 July 23rd, 2005 07:36 PM