Hi,
I've tried what you have suggested and so far, it doens't work. This is what I have done since:
Your suggestion is outputting none of the id numbers. So it's not selecting them properly or something.
Here is the code in full as it stands:
<?php
mysql_connect(localhost, user, pass);
mysql_select_db(dbname);
$download_me = $_GET['download_me'];
if($download_me) {
// make browser output downloadable
//header("Content-type: application/octet-stream");
//header("Content-Disposition: attachment; filename=registered.csv");
//header("Content-Transfer-Encoding: binary");
$result = mysql_query("SELECT id, firstname, lastname, email FROM userstest WHERE registered=1 LIMIT 400");
$query = "DELETE FROM userstest WHERE id=' ".$row['id']." ' ";
while($row = mysql_fetch_row($result)) {
print $query;
//$line = implode(",", $row) ."\n";
//print $line;
}
// this stuff is being downloaded; stop here before default stuff is printed
die;
}
printf("<div>Click here to <a href=\"%s\">download</a> registered users</div>",
$_SERVER['PHP_SELF'] . "?download_me=true"
);
?>
I added print command to show the ID select query and I end with lots of the following:
DELETE FROM userstest WHERE id=' '
Over and over...
So I'm not sure what it is, but the row id isn't getting selected properly.