...

View Full Version : whats wrong with this query?



kesikkafa
01-03-2006, 06:41 PM
$query = "INSERT INTO registeredcourses (Grade) VALUES (2) where StudentNo=$z AND CourseCode='c1' ";

Velox Letum
01-03-2006, 07:15 PM
We can't really help you with the limited amount of information you've given us. A table layout would be nice, as well as the output of:


$query = "INSERT INTO registeredcourses (Grade) VALUES (2) where StudentNo=$z AND CourseCode='c1' ";
mysql_query($query) or die(mysql_error());

which would give us a MySQL error to help debug your problem.

kesikkafa
01-03-2006, 07:22 PM
http://www.kesikkafa.com/proj/3.gif

eksob
01-03-2006, 07:23 PM
somethign like this?



$query = "INSERT INTO registeredcourses VALUES grade='2' where StudentNo='$z' AND CourseCode='c1' ";


although you will get an error if you need to fill in other fields

kesikkafa
01-03-2006, 07:27 PM
so should i use UPDATE ??

eksob
01-03-2006, 07:29 PM
so should i use UPDATE ??

well your not specifying what you need to do.

Insert, if you want to insert a whole new record. From what it looks like if you want to add a bunch of grades to a students record, than you would need a seperate table for grades.

But if the student just has 1 grade, than you would use update.

message me if you don't want to talk about your program in public

kesikkafa
01-03-2006, 07:35 PM
for example i want to ad garde A to coursecode c1 to student 058686
students can have more than 1 course.so maybe i need add 2 grades for one student.you say this table dont work for this proceses?

eksob
01-03-2006, 07:59 PM
ok, well here is your update query:



$update = mysql_query("UPDATE registeredcourses SET grade='2' WHERE StudentNo='$z' AND CourseCode='c1'") or die (mysql_error());

I still am thinking that your structure is off, but whatever works for you is fine :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum