473,399 Members | 3,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

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>Gradebook</TITLE>
<LINK REL="STYLESHEET" TYPE="text/css" HREF="../stylesheets/gradebook.css">
</HEAD>

<BODY>
<?PHP
include("connect.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="instructions">
<FORM ACTION="entergrades.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($SQL, $CONNECTION) OR die ('Query failed: ' .
mysql_error());
while ($ROW = mysql_fetch_array($RESULT))
{
$CLASSID = $ROW["classid"];
$CNAME = $ROW["classname"];
echo "<OPTION VALUE='$CLASSID'>$CNAME</OPTION>";
}
?>
</SELECT>
<INPUT TYPE='submit' NAME='checkclass' VALUE="Submit">
</FORM>

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

echo "<FORM ACTION='entergrades.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($SQL, $CONNECTION) OR die ('Query failed: ' .
mysql_error());
$NUM = mysql_num_rows($RESULT);
if ($NUM > 0)
{
while ($ROW = mysql_fetch_array($RESULT))
{
$AID = $ROW["record"];
$ANAME = $ROW["name"];
$VALUE = $ROW["value"];
echo "<OPTION VALUE='$AID'>$ANAME ($VALUE)</OPTION>";
}}
echo "</SELECT>";
echo"<INPUT TYPE='submit' NAME='checkassign' 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($SQL2, $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'>$CNAME</TH></TR>";
echo "<TR><TH>ID#</TH><TH>Student</TH><TH>Grade</TH><TH></TH></TR>";
echo "<FORM ACTION='entergrades.php' METHOD='post'>";
while ($ROW = mysql_fetch_array($RESULT2))
{
$SRECORD = $ROW["record"];
$SID = $ROW["studentid"];
$FNAME = $ROW["firstname"];
$LNAME = $ROW["lastname"];
echo "<TR><TD>$SID</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 1380
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
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...
32
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...
9
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...
2
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...
3
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...
9
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...
7
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...
2
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...
7
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...
14
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.