473,320 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 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 9298
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Oliver | last post by:
Hello, i'm having trouble with a css type popup. It's not doing what i want in Mozilla 1.6 and in IE6.0 it's not working at all. The html code looks like this: <div class="themenkueche"...
4
by: DBQueen | last post by:
I have a subform which is in Continuous Forms view. I have added a button to the bottom of the page to move to the next record using the button wizard (result: DoCmd.GoToRecord , , acNext). I...
2
by: ruby_bestcoder | last post by:
Hi Im having problem in firefox with display:none/block. I have essentially 3 li elements. In each element there are a few nested div:s. Clicking on one of the divs, makes another div to...
2
by: magix | last post by:
Hi, I'm using Access Database with ASP. There is one particular thing that I have issue with. My purpose is for user to update their own profile. Their existing profile information will be...
5
by: CES | last post by:
All, I was hoping that someone might be able to help me with a few questions on Aligning Block Elements properly... Basically I have a row that has a fixed width of 900px. Within the row their is...
3
by: Jannette | last post by:
I've got this to finally work in IE (its only taken me 2 days solid), but now mozilla isn't displaying the text on the same line as the image. I'm a newby at CSS, and I've think I've worked on trying...
0
by: adamselearning | last post by:
I have HTML content defined in an external XML file: I am using code to identify when a <p> tag is present, so it is not treated as an XML node. I'm also using CDATA in some cases, and still...
2
by: wreed06 | last post by:
Hello, I have 2 problems. In my webpage, I have a dropdown list with a button that takes the user to a popup window specific to the option. I am using Firefox 2.0.0.13. I have successfully...
3
by: Zaur Bahramov | last post by:
Hi! I'm developing a web application where the first page shows table from SQL Server and has some hyperlinks in one collumn. The collumn has productID so when clicked the page is passed as...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.