Announcements | Last Post | |
---|---|---|
SoC Curricula | 09/30/2017 01:08PM | |
Demarcation or scoping of examinations and assessment | 02/13/2017 07:59AM | |
School of Computing Short Learning Programmes | 11/24/2014 08:37AM | |
Unisa contact information | 07/28/2011 01:28PM |
the course_man page for the Project September 17, 2010 01:04PM |
Registered: 13 years ago Posts: 64 Rating: 0 |
Language: HTML<html> <head> <title>Add Course</title> </head> <body> <form method=';GET'; action=';course_man.php';> Add Course Name <input name=';course_name'; type=';text';> <br> <br> <input name=';option'; type=';hidden'; value=';add';> <input type=';submit';> </form> </body> </html>
Language: PHP<?php $title = "Course Manager"; /*connecting to the database*/ $link_id = mysql_connect("localhost", "lizwe", ""); mysql_select_db("registration"); /*testing connection*/ if ($link_id) echo "Success in connecting!"; else echo "Failed to connect."; /*Doing this so that program doesn';t enter the same record again*/ if (empty ($_GET[';option';])) { $option = "none"; } /*Getting the value of "option" variable from the "add_course" form*/ else $option = $_GET[';option';]; /*selecting appropriate action to take based on the value of "option" variable*/ switch ($option) { case "add": /*getting the value of "course_name" variable from the add_course.html page*/ $course_name = $_GET[';course_name';]; /*inserting value of "course_name" variable into the table "course"*/ $query = "INSERT INTO course VALUES (';$course_name';, ';';)"; $result = mysql_query($query); /*to test if the record was added to the database*/ $rows = mysql_affected_rows(); if ($rows < 1) echo "Error. The record has not been added."; else echo "$rows record has been added"; break; } /*The following table writes the "Add Course" link*/ echo "<table border=';0'; width=';600'; cellspacing=';0'; cellpadding=';0';>"; echo "<tr>"; echo "<td width=';60%';>"; echo "<a href=';add_course.php';>Add Course</a>"; echo "</td>"; echo "</tr>"; echo "</table>"; /*The following code lists the records in the "course" table*/ echo "<table border=';1'; width=';600'; cellspacing=';0'; cellpadding=';0';>"; $result = mysql_query("SELECT * FROM course"); while ($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td width=';60%';>"; echo $row["cname"]; echo "</td>"; echo "<td width=';20%';>"; echo "Delete"; echo "</td>"; echo "<td width=';20%';>"; echo "Edit"; echo "</td>"; echo "</tr>"; } echo "</table>"; /*this line deletes the "option" variable and all memory allocated to it.Without this line, the same value for the "option" variable from "add_course.html" would remain when the page is refreshed. And so the "switch/case ';add'; " would be entered again and so inserting the same record */ unset($_GET[';option';]); ?>
Re: the course_man page for the Project September 17, 2010 03:07PM |
Admin Registered: 18 years ago Posts: 10,001 Rating: 353 |
Language: PHP//mysql select query e.g. "select from course where cname=.';$course_name';". $rows=mysql_num_rows....... if($rows > 0) { //i.e. there is already a row with a course name like this echo "Course already exists <a href......>Try again</a>"; } else { //insert record }
Re: the course_man page for the Project September 17, 2010 06:41PM |
Registered: 13 years ago Posts: 64 Rating: 0 |
Re: the course_man page for the Project September 22, 2010 03:43PM |
Registered: 13 years ago Posts: 64 Rating: 0 |
Re: the course_man page for the Project September 22, 2010 04:00PM |
Admin Registered: 18 years ago Posts: 10,001 Rating: 353 |
Re: the course_man page for the Project September 22, 2010 04:13PM |
Registered: 13 years ago Posts: 64 Rating: 0 |
Re: the course_man page for the Project September 22, 2010 04:27PM |
Registered: 13 years ago Posts: 64 Rating: 0 |
Re: the course_man page for the Project September 23, 2010 07:18AM |
Admin Registered: 18 years ago Posts: 10,001 Rating: 353 |
Re: the course_man page for the Project September 25, 2010 07:15PM |
Registered: 13 years ago Posts: 64 Rating: 0 |
Re: the course_man page for the Project September 27, 2010 06:51AM |
Admin Registered: 18 years ago Posts: 10,001 Rating: 353 |
Re: the course_man page for the Project September 27, 2010 04:13PM |
Registered: 13 years ago Posts: 64 Rating: 0 |
Re: the course_man page for the Project September 28, 2010 07:56AM |
Admin Registered: 18 years ago Posts: 10,001 Rating: 353 |
Re: the course_man page for the Project September 30, 2010 10:47AM |
Registered: 13 years ago Posts: 64 Rating: 0 |
Re: the course_man page for the Project September 30, 2010 11:38AM |
Admin Registered: 18 years ago Posts: 10,001 Rating: 353 |
Re: the course_man page for the Project September 30, 2010 12:23PM |
Registered: 13 years ago Posts: 64 Rating: 0 |
Re: the course_man page for the Project September 30, 2010 04:17PM |
Registered: 13 years ago Posts: 64 Rating: 0 |
Re: the course_man page for the Project October 01, 2010 07:02AM |
Admin Registered: 18 years ago Posts: 10,001 Rating: 353 |