I'm sure this has been touched on before, I just can't find anything.
Basic stuff I guess, I know how to write and read text files but what I want to do is take my text file and list each line in a form with a checkbox next to it.
If you click on a check box and hit submit or in this case delete it would then delete that line.
It is a text file of email address and names each on different lines.
name,email
name,email
name,email
and so on
I know how to do most of this just not the checkboxes and delete of a line.
Could anyone help?
TIA
Wes/
check boxes to delete lines??
Moderator: General Moderators
- Sevengraff
- Forum Contributor
- Posts: 232
- Joined: Thu Apr 25, 2002 9:34 pm
- Location: California USA
- Contact:
OK this is what I came up with for displaying the text inside a form with radio buttons. This works like a charm.
once the radio button is checked and the form is submitted. I want it to display what info is being deleted before it gets deleted.
Right now it will display the correct line number but as for the email and initials, only the last line displays. How can I display the correct information from the line I want to delete.
This is what I submit the form to for testing the output:
Anyone know how to get the right info from each line?
Wes/
Code: Select all
<?php
$email == array();
$initials == array();
// Get a file into an array. In this example we'll go through HTTP to get
// the HTML source of a URL.
$email_list= "fake_email_lists.txt";
$lines = file ($email_list);
echo $email_list;
//echo "<br><table width="70%" border="0" cellspacing="0" cellpadding="1">";
//echo "<form name ="email" action ="delete_email.php">";
// Loop through our array, show html source as html source; and line numbers too.
foreach ($lines as $line_num => $line) {
$split = explode( ",", $line);
$initials = $split[0];
$email = $split[1];
$initials = strtoupper($initials);
$email = strtoupper($email);
//WRITE THE NOTE LISTING
echo "<tr><td width="35"><font size="3" face="Arial" color="#DC143C">$line_num</td><td width="80"><font size="3" face="Arial" color="#003366"><b>$initials</b></td><td width="230"><font size="2" face="Arial" color="#003366">$email</td><td><input type="radio" name="line" value="$line_num" border="0"><br></td></tr>";
}
?>Right now it will display the correct line number but as for the email and initials, only the last line displays. How can I display the correct information from the line I want to delete.
This is what I submit the form to for testing the output:
Code: Select all
<?php
$line = $_POST['line'];
$email = $_POST['email'];
$initials = $_POST['initials'];
echo $line;
echo "<br>";
echo $initials;
echo "<br>";
echo $email;
?>Wes/
I'm not totally sure what you mean but my guess is that you have some checkboxes and when you click more then one it only shows the last result.
Read this tutorial for some help using checkboxes:
http://codewalkers.com/tutorials/12/4.html
Read this tutorial for some help using checkboxes:
http://codewalkers.com/tutorials/12/4.html
Actually everything is working fine from the check box, It is only passing the line number.
The problem I'm having now is when I want to display the email and initials, it is displaying the last last line of the text file, because it was the last thing added to the email and initials arrays.
My question is how do I pass the correct email and initials to the next page.
I hope that is a little clearer.
Wes/
The problem I'm having now is when I want to display the email and initials, it is displaying the last last line of the text file, because it was the last thing added to the email and initials arrays.
My question is how do I pass the correct email and initials to the next page.
I hope that is a little clearer.
Wes/