Originally posted by: lilcam
wow ... works like a charm however here's where it gets tricky. so far with your help i'm able to import the contacts i checked off. howerver, we know our address book isnt perfect. havent said that i noticed many of my contacts have just their first name or an email address as their display name. so, importing these contacts will be weird if it pulls it through with the email address listed as their first name.
so, i was thinking of taking it a step further. The html page that is displayed contains a checkbox and two input boxes.
The input boxes are nothing more than just the name and email displayed. Your code has the name/email passed in the checkbox's array but let's say I wanted to pass the field value from both input boxes? What I'm trying to get at is for the user to be able to modify the name before they import it into the db table. so say i check off two contacts and I wanted to modify the name for these two contacts, i would like to pass the value from the name field and not through the checkbox array. makes sense?
makes perfect sense!
there's several ways go to about it though.
on the form, put the text fields there and populate them with any name data you have (if none, leave blank)
name each field using an identifier PLUS the id
so if your ID is 3, the fName field could be <input type="text" name="fName3" value="">
also add the email as hidden (or text if you want it editable)
then use some variable variables on the action page to snag the data.
i haven't tested this, but it shold work
edit: jees, code attach sucks
<?
// form page
?>
<input type="checkbox" name="id[]" value="3">
<input type="hidden" name="email3" value="john@doe.com">
<input type="text" name="fName3" value="Display name, if you got it">
<?
// action page
$values = array(); // blank array to hold insert values (better than using a string)
foreach($checkArr as $items)
{
if(isset($_GET['fName'.$items]) && strlen(trim($_GET['fName'.$items])))
$thisFname = $_GET['fName'.$items];
if(isset($_POST['email'.$items]) && strlen(trim($_POST['email'.$items])))
$thisEmail = $_POST['email'.$items];
$values[] = "('" . $thisFname . "','" . $thisEmail . "')";
}
// then your query will look like
if(count($values))
{
$sql = "INSERT into test (f_name, email_home) values " . implode(",",$values);
mysql_query($sql);
}
?>