Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-29-2012, 06:18 PM   PM User | #1
jcdevelopment
Senior Coder

 
jcdevelopment's Avatar
 
Join Date: Oct 2007
Location: Cowboy Nation
Posts: 2,171
Thanks: 173
Thanked 257 Times in 257 Posts
jcdevelopment will become famous soon enoughjcdevelopment will become famous soon enough
Adding numbers to each row

I have this current code that easily spits out entered data along with a time stamp.

PHP Code:
<?php
$db 
mysql_connect('*','*','*');
mysql_select_db('*',$db);

$sel "SELECT * from rsvp_101";

$q mysql_query($sel,$db);
echo 
"<table>";
while (
$row mysql_fetch_assoc($q)) {


  
$first_name $row['first_name'];
  
$last_name $row['last_name'];
  
$office $row['office'];
  
$guests $row['guests'];
  
$date $row['date'];
 


  echo(
"
  
  <tr><td>$first_name $last_name </td> <td>$office </td><td> Guests attending: $guests</td><td> $date</tr>
  
  <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
  <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
  "
);
  
            

  
}

?>
I am just looking for a solution in PHP to add, in numerical order, a number on each line repeating. Does anyone know of a way so it will look something like this:

1 name office date
2 name office date
3 name office date
etc....

thanks for any help.
jcdevelopment is offline   Reply With Quote
Old 02-29-2012, 06:24 PM   PM User | #2
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,046
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
like this?

PHP Code:
<?php 
$db 
mysql_connect('*','*','*'); 
mysql_select_db('*',$db); 

$sel "SELECT * from rsvp_101"

$q mysql_query($sel,$db); 
echo 
"<table>"

$line=1;

while (
$row mysql_fetch_assoc($q)) { 


  
$first_name $row['first_name']; 
  
$last_name $row['last_name']; 
  
$office $row['office']; 
  
$guests $row['guests']; 
  
$date $row['date']; 

echo(

   
  <tr><td>$line</td><td>$first_name $last_name </td> <td>$office </td><td> Guests attending: $guests</td><td> $date</tr> 
   
  <tr><td>&nbsp;</td><td>&nbsp;</td></tr> 
  <tr><td>&nbsp;</td><td>&nbsp;</td></tr> 
  "
); 
$line++;

            

   


?>
mlseim is offline   Reply With Quote
Users who have thanked mlseim for this post:
jcdevelopment (02-29-2012)
Old 02-29-2012, 06:34 PM   PM User | #3
jcdevelopment
Senior Coder

 
jcdevelopment's Avatar
 
Join Date: Oct 2007
Location: Cowboy Nation
Posts: 2,171
Thanks: 173
Thanked 257 Times in 257 Posts
jcdevelopment will become famous soon enoughjcdevelopment will become famous soon enough
could have sworn i tried that.... It never worked, probably placed it in the whil statement. Thanks!
jcdevelopment is offline   Reply With Quote
Reply

Bookmarks

Tags
php line counter

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:22 PM.


Advertisement
Log in to turn off these ads.