Welcome! Log In Create A New Profile

Advanced

deleting multiple students

Posted by PeterJ 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
avatar deleting multiple students
September 26, 2011 09:49PM
Ok I have an array with the sno 's that i want to delete from the student table
I cant seem to get it to delete the buggers
Let me show what ive been trying

Here I thought i would implode the array and insert the multiple sno's string into the delete query
using the IN operator

Quote
The IN operator allows you to specify multiple values in a WHERE clause.
I thought this was pretty neat.. smiling smiley
anywayzz

Language: PHP
$types = array();   while(($row = mysql_fetch_array($sno_query))) { $types[] = $row[';sno';]; }   $keys = implode(",", $types);   $sql = "DELETE FROM student WHERE sno IN (';".$keys."';)";

Doesnt work sad smiley
Then I thought let me try delete each student with each loop

Language: PHP
$types = array();   while(($row = mysql_fetch_array($sno_query))) { $types[] = $row[';sno';]; $sql = "DELETE FROM student WHERE sno = ';".$row[';sno';]."';";   }

no luck either
What am i missing here?.....
it makes sense to me... :p Ive also checked the queries in phpmyadmin
cause by golly ive googled and i cant seem to get this one
avatar
Mac
Re: deleting multiple students
September 27, 2011 07:53AM
Language: PHP
$count_array = count($Day); //$Day is the array for($i=0; $i < $count_array; $i++){ $day=$Day[$i]; mysql_query("DELETE FROM xxxx WHERE day=';$day'; "); }
avatar Re: deleting multiple students
September 27, 2011 09:01PM
Thanks Mac, making sure I back this piece up, seems it can be used in many other situations
My MC1 and MC2 are now complete smiling smiley
Sorry, only registered users may post in this forum.

Click here to login