By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,191 Members | 1,256 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,191 IT Pros & Developers. It's quick & easy.

How to display first record in bold

P: 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

Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.