473,807 Members | 2,823 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

multiple problems in creating an application

LS
1. When I select an assignment, the class roster disappears. I don't want it to show up until I select an assignment.

2. I want to be able to enter grades and submit all with only one submit button.

This is my code. File is loaded at http://lynnesmith.net/teacher/entergrades.php
+++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++
<HTML>
<HEAD>
<TITLE>Gradeboo k</TITLE>
<LINK REL="STYLESHEET " TYPE="text/css" HREF="../stylesheets/gradebook.css">
</HEAD>

<BODY>
<?PHP
include("connec t.php");
$CONNECTION = mysql_connect($ DB_SERVER, $DB_USER, $DB_PASS) or die ('I
cannot connect to the database because: ' . mysql_error());
mysql_select_db ($DB_NAME) or die("Couldn't select database.");
?>
<DIV ID="header">
Enter Grades
</DIV>
<DIV ID="instruction s">
<FORM ACTION="entergr ades.php" METHOD="post">
<SELECT NAME='classid' SIZE='1'>
<OPTION VALUE='0' SELECTED>--- Select Class ---</OPTION>
<?PHP
$SQL = "SELECT * FROM $DB_TABLE ORDER BY classname";
$RESULT = mysql_query($SQ L, $CONNECTION) OR die ('Query failed: ' .
mysql_error());
while ($ROW = mysql_fetch_arr ay($RESULT))
{
$CLASSID = $ROW["classid"];
$CNAME = $ROW["classname"];
echo "<OPTION VALUE='$CLASSID '>$CNAME</OPTION>";
}
?>
</SELECT>
<INPUT TYPE='submit' NAME='checkclas s' VALUE="Submit">
</FORM>

<?PHP
if(isset($_POST['checkclass']))
{
$CID = $_POST['classid'];

echo "<FORM ACTION='entergr ades.php' METHOD='post'>" ;
echo "<SELECT NAME='assignid' SIZE='1'>";
echo "<OPTION VALUE='0' SELECTED>--- Select Assignment ---</OPTION>";

$SQL = "SELECT * FROM $DB_TABLE1 WHERE classid = '$CID' ORDER BY name";
$RESULT = mysql_query($SQ L, $CONNECTION) OR die ('Query failed: ' .
mysql_error());
$NUM = mysql_num_rows( $RESULT);
if ($NUM > 0)
{
while ($ROW = mysql_fetch_arr ay($RESULT))
{
$AID = $ROW["record"];
$ANAME = $ROW["name"];
$VALUE = $ROW["value"];
echo "<OPTION VALUE='$AID'>$A NAME ($VALUE)</OPTION>";
}}
echo "</SELECT>";
echo"<INPUT TYPE='submit' NAME='checkassi gn' VALUE='Submit'> ";
echo "</FORM>";
}

if (isset($_POST['checkassign']))
{
$AID = $_POST['assignid'];
}
?>
</DIV>
<DIV ID="content">

<?PHP
$SQL2 = "SELECT * FROM $DB_TABLE2 WHERE classid = '$CID' ORDER BY
lastname, firstname";
$RESULT2 = mysql_query($SQ L2, $CONNECTION) OR die ("Query failed.");
$NUM2 = mysql_num_rows( $RESULT2);
if ($NUM2 > 0)
{
echo "<TABLE CELLSPACING='2' CELLPADDING='2' BORDER='1'>";
echo "<TR><TH COLSPAN='4'>$CN AME</TH></TR>";
echo "<TR><TH>ID #</TH><TH>Student</TH><TH>Grade</TH><TH></TH></TR>";
echo "<FORM ACTION='entergr ades.php' METHOD='post'>" ;
while ($ROW = mysql_fetch_arr ay($RESULT2))
{
$SRECORD = $ROW["record"];
$SID = $ROW["studentid"];
$FNAME = $ROW["firstname"];
$LNAME = $ROW["lastname"];
echo "<TR><TD>$S ID</TD><TD>$LNAME, $FNAME</TD><TD><INPUT TYPE=text
NAME='grade' SIZE='3' MAXLENGTH='3'></TD></TR>";
}
echo "</FORM>";
echo "<TR><TD COLSPAN='4' ><INPUT TYPE='submit' NAME='grades' VALUE='Add
Grade'></TD> </TR>";
echo "</TABLE>";
}
?>
<?PHP
if(isset($_POST['grades']))
{
$ANUM = $_POST['anum'];
$GRADE = $_POST['grade'];
$SQL3 = "INSERT INTO $DB_TABLE3 (classid, studentid, assignmentid,
grade) VALUES ('$CID', '$SID', '$AID', '$GRADE')";
}
?>
</DIV>
</BODY>
</HTML>
Jul 17 '05 #1
1 1391
LS wrote:
1. When I select an assignment, the class roster disappears. I don't
want it to show up until I select an assignment.

2. I want to be able to enter grades and submit all with only one submit
button.

[snip]

Just by looking at the live example, I think the problem to your first
question is that you do not setup the class select box after you choose
a class. It goes back to the default value of --- Select Class ---, so
when you select an assignment and submit, your script does not see a
selected class and displays the orginal page again. So when you create
your class drop down, you need to have a check for if a class has been
choosen, auto-select it on when it's time to choose an assignment.

Same would go for assignment. You'll need to make it automatically
selected once it has been choosen.

For your second question, you'll want to name the grade boxes as an
array. And you might use the student id as the index, just to make
things easier in the script.

<input type="text" name="grade[$SID]">

<?php

foreach ($_POST['grade'] as $sid=>$grade){
//Update database, set grade for student $sid to $grade
}

?>
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1437
by: Charles A. Lackman | last post by:
I am working on a application that has many custom made dlls. Actually, for this app each dll is a different form. I am able, with no problem to reference and instantiate them to use their public properties and methods with no problem. But, if one dll is trying to access another dll's properties (this does not work very good) the project tries to copy the dll to the directory which already contains the dll and the app will not compile. ...
32
14918
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if ((someString.IndexOf("something1",0) >= 0) || ((someString.IndexOf("something2",0) >= 0) ||
9
23088
by: Abhishek Srivastava | last post by:
Hello All, In IIS 6.0 We have a concept of worker processes and application pools. As I understand it, we can have multiple worker process per appliction pool. Each worker process is dedicated to a pool. If I assign only one application to a applicaton pool and have multiple worker processes assigned to that pool. Will my application be processed by many worker processes?
2
2274
by: Marcus | last post by:
I have seen many posts of people with the same problem as me (attached below), but I have yet to see any solutions posted. Has anyone figured out how to deploy an Asp.net web site to the webserver in any place other than the default website? I do not want to install it there as our IIS has multiple websites, but nowhere is there an option when creating the install package in Visual Studio to specify what website on the server you want to...
3
1924
by: SL | last post by:
All, As I understand it, a single application (i.e. IIS virtual directory) in ASP.NET may in fact have more than one corresponding HttpApplicationState object (more or less one per server thread, I think). During each request, only one of these objects is exposed to the page as Page.Application. This seems to be supported by the fact that when I use the debugger, I can see the Application_Start event firing more than one time even...
9
2780
by: Graham | last post by:
I have been having some fun learning and using the new Controls and methods in .Net 2.0 which will make my life in the future easier and faster. Specifically the new databinding practises and wizards. But, I have found that trying to do something "outside the norm" adds a rather large level of complexity and/or data replication. Background I have been commissioned to create a web-based application for a client. It has a formsaunthentication...
7
3117
by: Siv | last post by:
Hi, I have an MDI application that uses a generic "ShowPage" routine in a module that is called when I want to display a child form. The basic idea is that in the module I have declared each form as follows: Friend F0 As frmMain Friend F1 As frmStart Friend F2 As frmSearch Then in my ShowPage routine (which is passed a string "pageToShow" which is the name of the form I wish to open), I first check to see if we already have an instance...
2
1668
by: Helen Trim | last post by:
I have an application with three forms that are msde visible and activated when needed. It uses Word to open documents and one of the forms is opened as the Word document is closed in the DocumentBeforeClose event. It works the first time but when it makes the form visible for the second time, it freezes. Sometimes it gives an out of memory error, but I think that may be a red herring. Any ideas? Has anyone come across similar...
7
6254
by: Dave | last post by:
Apologies for the newbie question. I have created a vb.net program for my company that is designed to work with Word Templates (about forty of them that we commonly use) that are selected by the user and populated (with info from an Access database) at run-time, then saved as Word documents. The program I have coded works fine -- it does what I need it to do. But it has two problems: (1) it runs very slowly, and (2) it does not seem to...
14
3371
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using VS2005 and .net 2.0. I'm creating an application that has 3 forms. I want allow users to move forward and backward with the forms and retain the data users have entered. I thought I'll make the inactive forms invisible but this is creating a memory corruption problem when user close the form2 or form3 and not the formMain. My main form has a Next button which makes the main form invisible and starts a new form which I'll...
0
9719
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9599
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10624
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10371
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5684
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4330
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3010
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.