php help
Posted: Tue Mar 11, 2014 10:28 pm
Here is what i am trying to do
- i am suppose to open the file put it into an array
- delete something in the array
- rewrite the array back into the file
and spit it back out
i dont know what i am doing wrong
please help me
- i am suppose to open the file put it into an array
- delete something in the array
- rewrite the array back into the file
and spit it back out
i dont know what i am doing wrong
please help me
Code: Select all
<?php
$visitor = fopen("guestbook.txt", "ab");
$countvisit = count($visitor);
for ($i = 0; $i < $countvisit; ++$i){
$visitor = explode(",", $visitor[$i]);
fclose($visitor);
}
$del = ($_POST['visitor']-1);
$redit = array_splice($visitors, $del, $del, NULL);
echo $redit;
$visitor1 = fopen("guestbook.txt", "w");
fwrite($visitor1, $redit);
fclose($visitor);
$viewgb = file("guestbook.txt");
echo "<table style=\"background-color:gray\" border=\"1\" width=\"100%\">\n";
$countvisit = count($viewgb);
for ($i = 0; $i < $countvisit; ++$i){
$visitor = explode(",", $viewgb[$i]);
echo "<tr>\n";
echo "<td width=\"5%\" style=\"text-align:center; font-weight:bold\">",($i + 1),"</td>\n";
echo "<td width=\"95%\"><span style=\"font-weight:bold\">Name:</span>",htmlentities($visitor[0]), "<br />\n";
echo "<span style=\"font-weight:bold\">Email:</span>". htmlentities($visitor[1])."</td>\n";
echo " </tr>\n ";
}
echo "</table>\n";