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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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>';
}

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.