NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page PHP echos table. How to automatically number rows?

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 09-03-2007, 11:23 PM THREAD STARTER               #1 (permalink)
NamePros Regular
Join Date: Dec 2005
Posts: 208
JsteRmX is an unknown quantity at this point
 



[resolved] PHP echos table. How to automatically number rows?


So I pulled some data from a mysql database and have it echoed into an html table. How can i make the HTML table automatically number the rows? I want the row #s to be independent from the mysql data so that i can sort by different variables.

Here is the code:

Code:
echo "<table border='0' p class ='style15' align='left'>
<tr>
<th>Student Name</th>
<th>Speech Title</th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['name'] . "</td>";
  echo "<td>" . $row['speech'] . "</td>";
  echo "</tr>";
  }
echo "</table>";
help is appreciated. Thank yoU!!
__________________
+ Domains I have for sale here
Last edited by JsteRmX; 09-11-2007 at 08:59 PM.
JsteRmX is offline  
Old 09-04-2007, 12:14 AM   #2 (permalink)
DNOA Certified Seller
 
RegFee's Avatar
Join Date: Apr 2005
Location: Arizona
Posts: 3,680
RegFee has a reputation beyond reputeRegFee has a reputation beyond reputeRegFee has a reputation beyond reputeRegFee has a reputation beyond reputeRegFee has a reputation beyond reputeRegFee has a reputation beyond reputeRegFee has a reputation beyond reputeRegFee has a reputation beyond reputeRegFee has a reputation beyond reputeRegFee has a reputation beyond reputeRegFee has a reputation beyond repute
 


Third World Education Third World Education Save The Children Baby Health Baby Health Baby Health Baby Health Baby Health Baby Health Baby Health Baby Health Baby Health Baby Health Baby Health Baby Health Baby Health Baby Health Baby Health Baby Health Baby Health Baby Health Baby Health Baby Health Baby Health
PHP Code:
echo "<table border='0' p class ='style15' align='left'>
????: NamePros.com http://www.namepros.com/programming/369966-php-echos-table-how-automatically-number.html
<tr>
<th>ID</th>
<th>Student Name</th>
<th>Speech Title</th>
</tr>"
;

//set counter variable
$counter 1;

while(
$row mysql_fetch_array($result))
  {
  echo 
"<tr>";
  echo 
"<td>" $counter "</td>";
  echo 
"<td>" $row['name'] . "</td>";
  echo 
"<td>" $row['speech'] . "</td>";
  echo 
"</tr>";
  
$counter++; //increment counter by 1 on every pass
  
}
echo 
"</table>"
__________________
Nombrex.com
RegFee is offline  
Old 09-04-2007, 01:45 AM THREAD STARTER               #3 (permalink)
NamePros Regular
Join Date: Dec 2005
Posts: 208
JsteRmX is an unknown quantity at this point
 



sweet! thank you. that was simple, eh? rep+
__________________
+ Domains I have for sale here
JsteRmX is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 02:24 PM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger