Hey,
I have a list of information in a database such as names and addresses. I want people to be able to download a file of these, but I only want these names and addresses to be given to one person.
So I wrote the following:
<?php
mysql_connect(localhost, user, pass);
mysql_select_db(dbname);
$result = mysql_query("SELECT id, firstname, lastname, email FROM userstest WHERE registered=1 LIMIT 10");
$file = fopen("registered.csv", "w");
while($row = mysql_fetch_row($result))
{
$line = implode(",", $row) ."\n";
fwrite($file, $line);
mysql_query ("DELETE FROM userstest WHERE id='$id'");
}
fclose($file);
echo "<font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\">File has been completed, click <a href='registered.csv'>here</a> to download the file.</font>";
?>
Now this selects the 10 people as required, but it doesn't delete their record from the database. Any ideas how I need to go about doing this, while it has the row selected?
Cheers,
Chris