Welcome! Log In Create A New Profile

Advanced

course_student table in database

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
course_student table in database
November 02, 2013 07:31PM
Hi all,

Funny thing happening.

When submit a student registration, the following happens in my course_student table:

| sno | cid | year | fmark|
| correct number is inserted| Array | 2013 | |

Why would the word 'Array' appear and not the actual course that was selected?
Coding for the drop-down list:

Language: PHP
<select multiple name="cid[]">';; while ($resultCourses = mysql_fetch_array($courses_query)) { echo ';<option value="';.$resultCourses[';cid';].';">';.$resultCourses[';cid';].'; - ';.$resultCourses[';cname';].';</option>';; }   echo ';</select>';

Coding for insert

Language: PHP
$insert_sql2="INSERT INTO course_student (sno, cid) VALUES (';$sno';, ';$cid';)";

Any ideas anyone?
Re: course_student table in database
November 02, 2013 07:47PM
No worries. Found my mistake! eye rolling smiley

My solution:

Language: PHP
$cselect=$_POST[';cid';];   $insert_sql2="INSERT INTO course_student (sno, cid) VALUES (';$sno';, ';$cselect';)";   if (!mysql_query($insert_sql2)) { die (';Error! ';.mysql_error()); }     //drop down   echo ';<select multiple name="cid">';; while ($resultCourses = mysql_fetch_array($courses_query)) { echo ';<option value="';.$resultCourses[';cid';].';">';.$resultCourses[';cid';].'; - ';.$resultCourses[';cname';].';</option>';; }   echo ';</select>


Now to figure out how to capture when more than one course is selected...
Re: course_student table in database
November 03, 2013 12:16AM
Hi Elizabeth,

Wow! you are pretty good at this. My code for that works but it really looks like it was written by an alien from cyberspace!

A good example on how to capture when more than course one is selected is on page 306 Chapter 10 in the textbook.
The JOIN, try changing the c with an s being "student etc,etc...."

Also battling to finish. Keep making silly mistakes that take ages to debug.

Regards CharlesU
Re: course_student table in database
November 03, 2013 02:20PM
Hi Charles,

Thank you! And thank you for the tip in the textbook. Will definitely take another look, must have read over it somehow.

I am going to keep working as much as possible and hope for the best. Afraid that I still will not be able to finish.

Regards
Sorry, only registered users may post in this forum.

Click here to login