Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Dec 2005
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    whats wrong with this query?

    Code:
    $query = "INSERT INTO registeredcourses (Grade) VALUES (2) where StudentNo=$z AND CourseCode='c1' ";

  • #2
    Senior Coder
    Join Date
    Apr 2005
    Location
    Colorado, United States
    Posts
    1,208
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:

    PHP Code:
    $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.
    "$question = ( to() ) ? be() : ~be();"

  • #3
    New Coder
    Join Date
    Dec 2005
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

  • #4
    New Coder
    Join Date
    Oct 2005
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts
    somethign like this?

    Code:
    $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

  • #5
    New Coder
    Join Date
    Dec 2005
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    so should i use UPDATE ??

  • #6
    New Coder
    Join Date
    Oct 2005
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by kesikkafa
    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

  • #7
    New Coder
    Join Date
    Dec 2005
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #8
    New Coder
    Join Date
    Oct 2005
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok, well here is your update query:

    Code:
    $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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •