Home > Ask the Enterprise Linux Experts > Questions & Answers > Adding row numbers to PHP code
Ask The Enterprise Linux Expert: Questions & Answers
EMAIL THIS

Adding row numbers to PHP code

Mike Hillyer EXPERT RESPONSE FROM: Mike Hillyer

Pose a Question
Other Enterprise Linux Categories
Meet all Enterprise Linux Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 12 January 2006
Is there any facility to number the output when retrieving data from a database using PHP? For example: 1.output1, 2.output2, and 3.output3


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
Android  (SearchEnterpriseLinux.com)
Free and open source software (FOSS)  (SearchEnterpriseLinux.com)
gOS  (SearchEnterpriseLinux.com)
Subversion  (SearchEnterpriseLinux.com)
yacc  (SearchEnterpriseLinux.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


While you could, perhaps, develop a way to generate a row number in a query, it should not be necessary to have a row number at query time. Many users have row ID values stored in their tables to assist with joins and where clauses. Others add row numbers at display time to help users distinguish rows, but PHP should not require row numbers to properly process data.

In any case, as MySQL does not have a row number meta-column, it would be better to add a row number in your PHP code while iterating rows by way of a counter or similar method.




Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



Linux Migration Advice: Unix-to-Linux, Windows-to-Linux
HomeNewsTopicsITKnowledge ExchangeTipsBlogsAsk the ExpertsMultimediaWhite PapersIT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2003 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts