471,851 Members | 979 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,851 software developers and data experts.

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

Jul 17 '05 #1
4 9219
dr. zoidberg wrote:
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


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
Jul 17 '05 #2
On Sat, 15 Nov 2003 01:28:27 +0100, "dr. zoidberg" <so*****@example.wrong>
wrote:
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


Just use a simple flag.

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

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 17 '05 #3
I noticed that Message-ID: <4h********************************@4ax.com>
from Andy Hassall contained the following:
Just use a simple flag.

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

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/
Jul 17 '05 #4
Andreas Paasch wrote:
dr. zoidberg wrote:
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

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

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
##-----------------------------------------------##
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Oliver | last post: by
2 posts views Thread by ruby_bestcoder | last post: by
5 posts views Thread by CES | last post: by
3 posts views Thread by Zaur Bahramov | last post: by
NeoPa
reply views Thread by NeoPa | last post: by
reply views Thread by YellowAndGreen | last post: by
aboka
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.