filling a php table wont stay inside the cells

I am trying to make a table containing both name and email. the first entry goes in great but after that it will be all messed up like the name being in the name field and the same for email. PLEASE HELP ME !!!
here is my code:

I have another script that takes the entries and makes it like (FirstName LastName~Email) in that format
[php]

Title
    <a href="addnewmember.php"><button>Add New Visitor</button></a>

    <a href="visitors.txt"><button>View Visitors.txt</button></a>

<a href="nomember.php"><button>Remove Member</button></a>

<a href="azsort.php"><button>A-Z sort</button></a>



<?php //Opens the text file fopen("visitors.txt", "r+"); //puts the content of the file in variable $contents $contents = file_get_contents("visitors.txt"); //Closes the file visitors.txt fclose("visitors.txt"); // takes the string and separates it using explode $contents = explode('~', $contents); //prints information into a table print""; print""; print""; print""; print""; for ($i = 0; $i < count($contents); $i+=2) { $Name = ($contents[$i]); $email =($contents[$i+1]); print""; print""; print""; print"
"; print""; } print"
NameEmail
$Name$email
"; ?>
[/php]

I think this
[php]$Name = ($contents[$i]);
$email =($contents[$i+1]);[/php]

should be something like this:
[php]$Name = $contents[$i][0];
$email = $contents[$i][1];[/php]

To be really sure you can always do the following to see how you’re pulling the array in:

[php]echo ‘

’;
print_r($contents);
echo ‘
’;[/php]

your table print command breaks it… the style sheet should have an open quote and a closed quote and needs to be reordered… you have the border command in the middle of it…

print"<table style='margin:0 auto ’ border=‘1’text-align:center’ >";

should be something like…

print “

”;
Sponsor our Newsletter | Privacy Policy | Terms of Service