0

Hey folks, I need help with displaying a php array in a html table. I already have it displaying but it keeps repeating the column headings over each entry and also I want each row of the table to be a different color. I figured that the repeating column headings are because the table is in the loop but I don't know where I should put it to repeat the entries.

<?php
$first_name = array(0=>'Kadeem Caesar',
								1=>'David',
								2=>' Maurishow',
								3=>'Huggins',
								4=>' Connor',
								5=>' James',
								6=>' Wilson',
								7=>' Norland',
								8=>' Philips',
								9=>' Caesar');
			
				
$email = array(0=>'me@hotmail.com',
								1=>'me2@hotmail.com',
								2=>'me3@hotmail.com',
								3=>'me4@hotmail.com',
								4=>'me5@hotmail.com',
								5=>'me6s@hotmail.com',
								6=>'me7@hotmail.com',
								7=>'me8@hotmail.com',
								8=>'me94@msn.com',
								9=>'me10@live.com');
							
								print "unsorted names and email addresses";
								$noentries = count ($first_name);
								print 'number of entries = '. $noentries;
for($i=0; $i<=9; $i++)
{
	
print<<<MENU
<html><head><title>address-book-content</title></head><body>
<table style="text-align: left; width: 1000px; height: 200px; background-color: blue;" border="" cellpadding="" cellspacing="">
   <tbody>
    <tr>
      <td style="vertical-align: top;"><h2>First Name</h2>
      </td>
      <td style="vertical-align: top;"><h2>Email Address</h2>
      </td>
    </tr>
    <tr>
      <td style="vertical-align: top;">$first_name[$i]
      </td>
      <td style="vertical-align: top;">$email[$i]
      </td>
    </tr>
  </tbody>
</table>
</body></html>
MENU;
}

Edited by KBL: n/a

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by diafol
0

This has been covered about 4 million times over the last few months. Search the forum for 'array table'.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.