Jump to content

[SOLVED] I'm trying to delete all rows where a column's content is equal 0


Presto-X

Recommended Posts

Hello Guys,

 

I'm trying to delete all rows in a table where a column's content is equal 0.

 

This table holds a course roster with all of the students that have signed up if their status is set to 0 that means they have not paid, 99% will be set to 1 but I want a way for the end user to be able to clean up the table of bad checkouts where the student was not able to sign up for one reason or another.

 

This is the code that I'm trying to use:

$query = "DELETE FROM jos_courses_roster WHERE status='0'";

 

I'm not sure if I have to loop this or what I thought I would ask on here what would be the best way to go about this, thanks guys.

Yes I'm sure there are entries with 0 there are 4 of them, this is my code:

 

if($_GET['clean']=="students"){
  $query = "DELETE FROM jos_courses_roster WHERE status='0'";
  mysql_query($query);
  echo "Deletion Complete!";
}

 

and this is the link that I'm using to call it:

index2.php?option=com_courses&act=configure&clean=students

Odd very odd, is this not almost the same code that I was using? now it's working lol

 

if($_GET['clean']=="students"){
  $query = "DELETE FROM jos_courses_roster WHERE status='0'";
  mysql_query($query) or die(mysql_error());
  echo '<div class="message">Deletion Complete!</div>';
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.