473,666 Members | 2,144 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Automatic numbering of table with results on webpage

Hello group,

the script on this page i use to show the standings in a league. It is shown
in a table on my webpage. But I don't know how to number the rows so that
the first row is number 1 the second 2 and so on, so that the numbers are
equal to the standings.

Who has a solution for this.

Thnx.

RotterdamStuden ts

SCRIPT
=============== =============== =============== =============== ==========
<?php
....[CUT]

$str_requete = "SELECT id,name,played, points FROM EkStandings ORDER BY
points ASC";

$result_article s = mysql_query ($str_requete,$ ezine_db) or
ezine_mysql_die ();

print ('<table width=75% border=1 bordercolor=#5B 441B
cellspacing=0>< font face=arial size=2><B>
<tr><td><font face=arial size=2 color=#957745>< B>Position:</B></td>
<td><font face=arial size=2 color=#957745>< B>Name:</B></td>
<td><font face=arial size=2 color=#957745>< B>Played:</B></td>
<td><font face=arial size=2 color=#957745>< B>Points:</B></td>
');

while ($articleDb =mysql_fetch_ob ject($result_ar ticles))
{
print("
<tr><td><font face=arial size=1 color=#5B441B>H ere i want the position
numbers</td>
<d><font face=arial size=1 color=#5B441B>$ articleDb->name</td>
<td><font face=arial size=1 color=#5B441B>$ articleDb->played</td>
<td><font face=arial size=1 color=#5B441B>< b>$articleDb->points</td>
</tr>
");
}

print ('</font></table>');

?>
Jul 17 '05 #1
6 2674
RotterdamStuden ts wrote:
the script on this page i use to show the standings in a league. It is shown
in a table on my webpage. But I don't know how to number the rows so that
the first row is number 1 the second 2 and so on, so that the numbers are
equal to the standings.
a) Get a new variable.
b) Initialize it to 1.
c) Print it to each row and
d) Increment it inside the loop.

SCRIPT
============== =============== =============== =============== ===========
<?php
...[CUT]

$str_requete = "SELECT id,name,played, points FROM EkStandings ORDER BY
points ASC";

$result_article s = mysql_query ($str_requete,$ ezine_db) or
ezine_mysql_die ();

print ('<table width=75% border=1 bordercolor=#5B 441B
cellspacing=0>< font face=arial size=2><B>
<tr><td><font face=arial size=2 color=#957745>< B>Position:</B></td>
<td><font face=arial size=2 color=#957745>< B>Name:</B></td>
<td><font face=arial size=2 color=#957745>< B>Played:</B></td>
<td><font face=arial size=2 color=#957745>< B>Points:</B></td>
');

/* a) and b) */
$standing_count er = 1;
while ($articleDb =mysql_fetch_ob ject($result_ar ticles))
{
/* replace your print
print("
<tr><td><font face=arial size=1 color=#5B441B>H ere i want the position
numbers</td>
<d><font face=arial size=1 color=#5B441B>$ articleDb->name</td>
<td><font face=arial size=1 color=#5B441B>$ articleDb->played</td>
<td><font face=arial size=1 color=#5B441B>< b>$articleDb->points</td>
</tr>
");
with another that uses $$standing_coun ter */
/* c) */
print("<tr> ... color=#5B441B>$ standing_count</td>...");

/* d) */
++$standing_cou nt;
}

print ('</font></table>');

?>


Happy Coding :-)

--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :
Jul 17 '05 #2
In message <2g************ @uni-berlin.de>, Pedro Graca
<he****@hotpop. com> writes
RotterdamStude nts wrote:
the script on this page i use to show the standings in a league. It is shown
in a table on my webpage. But I don't know how to number the rows so that
the first row is number 1 the second 2 and so on, so that the numbers are
equal to the standings.


a) Get a new variable.
b) Initialize it to 1.
c) Print it to each row and
d) Increment it inside the loop.


<snipped>

At the end of the loop, the method above will leave the variable set to
1 more than the number of rows printed. If that matters:

a) get a new variable
b) initialize it to 0
c) increment it inside the loop
d) print the row

--
Five Cats
Email to: cats_spam at uk2 dot net
Jul 17 '05 #3
In message <c7********@odb k17.prod.google .com>, PrisonerOfPain
<ha*****@punkas s.com> writes
Why not use a for loop?
for ($i = 0; $articleDb =mysql_fetch_ob ject($result_ar ticles); $i++)

What happens with this loop when mysql_fetch_obj ect runs out of
$result_article s to fetch?

I've always used a while loop:
$i = 0;

// Process each class
while( $row = mysql_fetch_obj ect (result_article s) )
{
$i++;
// print the stuff
}

--
Five Cats
Email to: cats_spam at uk2 dot net
Jul 17 '05 #4
Five Cats <ca*******@[127.0.0.1]> wrote in
news:jq******** ******@[127.0.0.1]:
In message <c7********@odb k17.prod.google .com>, PrisonerOfPain
<ha*****@punkas s.com> writes
Why not use a for loop?
for ($i = 0; $articleDb =mysql_fetch_ob ject($result_ar ticles); $i++)
What happens with this loop when mysql_fetch_obj ect runs out of
$result_article s to fetch?


It terminates.

I've always used a while loop:
$i = 0;

// Process each class
while( $row = mysql_fetch_obj ect (result_article s) )
{
$i++;
// print the stuff
}


The only difference between that structure and the OP's for loop is that
the "print the stuff" code sees $i starting from one rather than zero.
Jul 17 '05 #5
In message <Xn************ *************** ****@130.133.1. 4>, Eric Bohlman
<eb******@earth link.net> writes
Five Cats <ca*******@[127.0.0.1]> wrote in
news:jq******* *******@[127.0.0.1]:
In message <c7********@odb k17.prod.google .com>, PrisonerOfPain
<ha*****@punkas s.com> writes
Why not use a for loop?
for ($i = 0; $articleDb =mysql_fetch_ob ject($result_ar ticles); $i++)
What happens with this loop when mysql_fetch_obj ect runs out of
$result_article s to fetch?


It terminates.


That is what I wasn't sure about.

I've always used a while loop:
$i = 0;

// Process each class
while( $row = mysql_fetch_obj ect (result_article s) )
{
$i++;
// print the stuff
}


The only difference between that structure and the OP's for loop is that
the "print the stuff" code sees $i starting from one rather than zero.


I think that was what the OP wanted. BTW the real OP doesn't appear
here - they've got snipped somewhere along the line!

--
Five Cats
Email to: cats_spam at uk2 dot net
Jul 17 '05 #6
Thank you all very much it works now.
Jul 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2867
by: fatih kayaalp | last post by:
Hi, i have imported an access database into sqlserver 2000. In access, i have some table fields which were using automatic number as datatype. But i see that there is not a datatype in sqlserver like automatic no. I have to enter id numbers to my tables for each records automatically. Would anybody help me about solving this problem? Any idea? Thanks
10
26869
by: john T | last post by:
Is there anyway to vertically center a html table using css in such a way it does not alter the html table. When I tryied it just screws up.
3
2589
by: Chris | last post by:
Before I started to create table, etc to track unique form field record number assigments I thought I'd check to see if there is now a better way to do this in .NET. I have a parent form (table) and children form (table). Relationship equals one to many. I'd like to auto number the fields accordingly and traditionaly I assign a unique number based on a table value that I retrieve + 1. i.e. Parent record field value = 1 Children record...
2
2366
by: Patrick Olurotimi Ige | last post by:
When i run the code below with stored proc :- I get only the first table results :-"templates" even if i fill the dataset with another table for example category,pages etc.. Any ideas? Store procedure below:- ------------------------
54
3240
by: MLH | last post by:
I use A97 and do not always insert line numbers while writing procedures. I find it necessary to go back and add them later to aid in debugging. Nearly 3 years ago, something was mentioned in this NG to the effect that "...when you access a module programatically, there is a lines collection..." Have any of you experimented with your own procedures to aid in numbering lines? Would the lines collection be of some
1
1745
by: Michael Doubez | last post by:
Hello, I want to mix in the same document Parts that have automatically numbered sections and parts which section are not numbered. Is there any out of the box way to locally suppress the automatic numbering of section like in latex using \section*{} instead of \section{} ? Or should I customize the XSLT with a new kind of section
1
2707
by: Dan Somdahl | last post by:
Hi, I am new to ASP but have what should be a fairly simple task that I can't figure out. I need to parse a string from a single, semi-colon delimited, 60 character field (el_text) in a recordset and display the results in a table on a webpage (ASP) I can retrieve the recordset from the database and display the field data results in rows of a table but have the entire 60 character string in one cell. I need to break that string apart...
1
2645
by: Rajen | last post by:
I've a automatic configuration proxy (http://xxx.xxx.xxx.xxx/xyz.pac) which I use in the Internet explorer Lan Settings to access the net. How do I read a webpage by specifying this proxy in my PHP code. By the by, I'm using curl to read the remote webpage. I've tried the option curl_setopt($ch, CURLOPT_PROXY, 'http://xxx.xxx.xxx.xx/xyz.pac'); but didn't work.
0
1464
by: cephal0n | last post by:
Hi All! I have two table tblHome1, contains all the unique PinNo and tblHome2 contains a duplicated PinNo and description. I put an automatic numbering (ProdID) and set it as my index. What I want to do is make an automatic filtering and labeling method for my table. The reason for this is because I m handling more than 500 records and labeling them would take me forever, so I started with what I can understand, which is seeking 5 records...
0
8444
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8869
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8551
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7386
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5664
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4368
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2771
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1775
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.