Jump to content

Deleting multiple rows... ???


mikepuerto

Recommended Posts

Can anyone give me an idea as to why this does not work? I dont get any errors and it seems to run fine but does not delete the rows...

[code]
$file = $_GET['file'];
$lines = file($file);

foreach ($lines as $line_num => $line) {
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to the database');
mysql_select_db($dbname);
$query = "DELETE FROM largo1 WHERE id='$line'";
$result = mysql_query($query);
echo "$line deleted<br>";
}
mysql_close($conn);
[/code]
Link to comment
Share on other sites

The id column contains an auto_increment id. Each line of the file contains an ID that exists in the table. Therefore $line is the ID that I'm trying to delete. Not thinking about it very much i changed id="$line_num" resulting in the deletion of a a bunch of rows that i did not want to delete.

I have figured out that the script works. but it does not actually loop. It only deletes one.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.