west4me
Members-
Posts
16 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
west4me's Achievements
Member (2/5)
0
Reputation
-
[SOLVED] Upgraded to 5.1.29 connecting but not pulling info
west4me replied to west4me's topic in MySQL Help
That did the trick. I replaced the short tags and all is well. Thank you. -
My school recently updated our mysql to 5.1.29 and to PHP 5.2.6 Now a script that someone wrote for me no longer works. The connection is made but nothing is being populated to the page. Here is the script: <?php mysql_connect('localhost', 'username', 'password') or die(mysql_error()); mysql_select_db('tablename') or die(mysql_error()); function getName($table = 'names', $date = '') { $date = empty($date) ? date('Y-m-d') : $date; $day = date('z', strtotime($date)); $x = mysql_query("SELECT * FROM $table ORDER BY id"); $names = array(); while ($n = mysql_fetch_array($x)) $names[] = $n['name']; for ($x = 0; $x < $day; $x++) { $fname = array_shift($names); $names[] = $fname; } return $names[1]; } $male = getName('male'); $female = getName('female'); $manager = getName(); ?> Then in the html this is where the "name" gets put <h1><?= $manager; ?></h1> All the html displays and there are no connection errors. You can see the page here: http://www.hallsville.org/elementary/cunningham/moodle/daily/ I use this in my classroom everyday and it is driving me nuts. I have tried figuring it out but I am stuck. Any help would be appreciated.
-
Maybe I'm a little to new but I am having a difficult time making sense of the reply. Can anyone else chime in?
-
I am a total noob when it comes to databases. However I am trying to jump in and get my feet wet. I am a teacher and I am trying to make a way for me to easily store math grades. I am trying to get started but I just can't get my head around how to structure the database. Here is what I will need... 1. Student first and last name 2. Unit Number 3. Lesson Number 4. problem number (not number of problems) 5. grade for problem I just can't seem to grasp how the database should look, to be able to add students and then be able to give that student a particular grade for a certain problem, in a certain lesson, in a certain unit. Please any help would be appreciated.
-
I do not know what I am doing at all.... thought that should give you an idea where I am coming from. I am a teacher and to be as unbiased as possible I use a name randomizer script to call on students. I used to do this with a java script but it had to reload the page every time. I figured ajax would do the trick. I found a randomizer script and adopted it to my needs. The script is working wonderfully in Firefox but really craps out in IE. Since I know nothing about ajax I don't even know where to start. Any help would be appreciated. Here is the site that I use the script on: http://cunninghamclassroom.com/name/name.html Here is the code that runs on that page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Ajax with jQuery Example</title> <script type="text/JavaScript" src="/name/jquery.js"></script> <script type="text/JavaScript"> $(document).ready(function(){ $("#generate").click(function(){ $("#quote p").load("script.php"); }); }); </script> <style type="text/css"> body { background: #000; } form { margin: 0; padding: 0; } fieldset { border: 0; margin: 0; padding: 0; } #chooser ul { margin: 0; padding: 0; } #chooser li { list-style: none; width: 172px; height: 150px; } #chooser button { background: url(button-p.jpg) bottom left no-repeat; color: #fff; cursor: pointer; border: 0; display: block; font-family: "Lucida Sans Unicode", "Lucida Grande", "Trebuchet MS", Helvetica, Arial, sans-serif; margin: 0; padding: 0; width: 175px; height: 150px; } button h3 { background: top left no-repeat; font-size: 1.6em; font-weight: normal; letter-spacing: 2px; line-height: 50px; width: 175px; margin: 0; padding: 0; position: relative; left: -3px; } * html button h3 { position: static; } #chooser button p { color: #555; font-size: 1.6em; margin: 0; padding: 10px; text-align: center; width: 145px; } * html #chooser button p { font-size: .9em; } .basic button h3 { background-image: url(li-pro-h3.jpg); } #move { margin-left: 5px; margin-top: -21px; } </style> </head> <body> <div id="move"> <form id="chooser" action="#" method="get"> <fieldset> <ul> <li class="basic"><button type="submit" id="generate" value="Generate!"> <h3>Student</h3> <div id="quote"><p>Click It!</p></div> </button></li> </ul> </fieldset> </form> </div> </body> </html> And here is the script: <?php header("Cache-Control: no-cache"); // Ideally, you'd put these in a text file or a database. // Put an entry on each line of 'a.txt' and use $prefixes = file("a.txt"); // You can do the same with a separate file for $suffixes. $prefixes = array('Dylan','Brandon','Clerence','Stephen','Trey','Jadon','Blake','Torsten','Kaleb','Angelica','Brittany','Rosalie','Hope','Mackenzie','Makayla','Makayli','Alexis','Savanna'); // This selects a random element of each array on the fly echo $prefixes[rand(0,count($prefixes)-1)] . "" ?>
-
I teach third graders(8 year olds) and I am looking for a open source script that they can use to make websites. I have searched and searched but just can't seem to find anything. I would like it to be something like google pagebuilder but I would host the script. I need to host it to avoid adds and my students are not allowed to use email so this limits my choices. Does anyone know of anything that would work?
-
The current script I am running does not pull from the database for the names. You can see what I am using here: [url=http://cunninghamclassroom.com/daily/name.php]http://cunninghamclassroom.com/daily/name.php[/url] I am on a hosted server and I am not very familiar with the environment. This is what it says in my server information that is provided. operating system FreeBSD 4.11-STABLE mysql version mysql Ver 12.22 Distrib 4.0.16 perl version perl, v5.8.3 php version PHP 4.4.1 Is that what you need?
-
I am a teacher and I try to keep my class as un-biased as possible. To help me do this I draw random student names from a script. My problem is, I would like to do this with ajax so it is faster, I wouldn't have to wait on the page to reload each time. I have been searching for something that I could use but can't find anything. I have a mysql database that holds my students names for another script and I was wondering if someone could help me make an ajax script that would pull a random name from the database.
-
I had a site built for me and I had it working but something happend to the database that I was using. I either did something or something else happend. The error I get when I try to login is this: [code]Can't find file: 'classes.MYI' (errno: 2)[/code] any ideas of how to fix that? I also get that error when I view through phpmyadmin. I have a feeling I need to rebuild the database but I have no idea of how to write the .sql file. I can't reach the guy who built it. I l will list the code from all of the pages that the site uses, could someone take a look at it and write a new .sql file for me? I would be willing to make a donation for help. This is the dbconnect file: [code]<? $location = "localhost"; $user = ""; $password = ""; $db = ""; $conn = mysql_connect($location, $user, $password) or die("Could not connect to MySQL"); $db = mysql_select_db($db) or die("Could not select database".mysql_error()); ?>[/code] This is the admin file: [code]<?php /********************************************\ * * * class test administation * * copyright 2005 Phil Pedlar * * * \********************************************/ session_start(); if (!$_SESSION['username']) { header ("location: index.php"); } include ("dbconnect.php"); require_once("dbconnect.php"); ?> <html> <head> <title>Test Admin</title> <style> body { font: 12px verdana; } table { font: 12px verdana; } h2 { font: 16px verdana; font-weight: bold; } #results td { padding-left: 10px; padding-right: 10px; } #results td { padding-left: 5px; padding-right: 5px; } </style> </head> <body> <span>| <a href='admin.php?add=class'>Add Class</a> | <a href='admin.php?add=student'>Add Student</a> | <a href='admin.php?add=scores'>Add Scores</a> | <a href='admin.php?show=completetests'>View Complete Tests</a> |</span> <p /> <? //this section is for adding a class if ($_GET["add"] == "class") { if ($_GET["add"] == "class" && $_POST["classname"]) { $classname = $_POST["classname"]; $query = mysql_query("INSERT INTO classes (`classid`, `classname`) VALUES ('', '$classname')"); print "<p>Class $classname was succesfully added to the the classes list</p>"; exit(); } print "<p>Please type in the box below which classname you would like to add to the list</p>"; print "<form method='post'> <table style='width:300px;'> <tr><td>Classname</td><td><input type='text' name='classname' /></td></tr> <tr><td></td><td><input type='submit' value='Add Class' /></td></tr> </table> </form>"; //this section is for adding a student } else if ($_GET["add"] == "student") { if ($_GET["add"] == "student" && $_POST["student_classname"] == "select") { print "<p>You did not select a class for this student</p> <p><a href='admin.php?add=student'>back</a></p>"; exit(); } else if ($_GET["add"] == "student" && $_POST["student_studentname"] && $_POST["student_classname"]) { $studentname = $_POST["student_studentname"]; $classname = $_POST["student_classname"]; $query = mysql_query("INSERT INTO students (`studentid`, `student_name`, `classname`) VALUES ('', '$studentname', '$classname')"); print "<p>Succsfully added student: $studentname to class: $classname</p>"; exit(); } print "<p>Please type the name of the student you would like to add in the box and select the classname that they belong to.</p>"; print "<form method='post'> <table style='width:300px;'> <tr><td>Student Name:</td><td><input type='text' name='student_studentname' /></td></tr> <tr><td>Student Class:</td><td> <select name='student_classname'> <option value='select' selected='selected'>Select</option>"; $query = mysql_query("SELECT * FROM classes"); while ($row = mysql_fetch_array($query)) { print "<option value='".$row["classname"]."'>".$row["classname"]."</option>"; } print " </select> </td></tr> <tr><td></td><td><input type='submit' value='Add Student' /></td></tr> </table> </form>"; } else if ($_GET["add"] == "scores") { print "<p>Please select by what you would like to add scores</p> <p><a href='admin.php?add=scores&type=individual'>By Individual</a></p>"; if ($_GET["add"] == "scores" && $_POST["add_byclass"]) { print "<h2>Please select the student you would like to add results for</h2>"; $class = $_POST["add_byclass"]; $query = mysql_query("SELECT * FROM students WHERE classname = '$class'"); print "<form method='post'> <table> <tr><td>Student</td><td> <select name='add_byname' onchange='this.form.submit();'> <option value='select' selected='selected'>Select</option>"; while ($row = mysql_fetch_array($query)) { print "<option value='".$row["student_name"]."'>".$row["student_name"]."</option>"; } print "<input type='hidden' name='student_name' value='".$row["student_name"]."' /> </table> </form>"; exit(); } if ($_GET["add"] == "scores" && $_POST["add_byname"]) { $name = $_POST["add_byname"]; $query = mysql_query("SELECT * FROM students WHERE student_name = '$name' ORDER BY student_name"); if ($row = mysql_fetch_array($query)) { print "<form method='post' action='addscores.php'> <table id='addscore' border='1'> <tr><th>Name</th><th>Class</th><th>2 x 2</th><th>3 x 3</th><th>4 x 4</th><th>5 x 5</th><th>6 x 6</th><th>7 x 7</th><th>8 x 8</th><th>9 x 9</th> <th>10 x 10</th><th>11 x 11</th><th>12 x 12</th></tr>"; do { print "<td style='width:50px;'>".$row["student_name"]."</td><td style='width:50px;'>".$row["classname"]."</td>"; print "<td><select name='add_2by2'><option value='".$row["2by2"]."'>".$row["2by2"]."</option><option value='Pass'>Pass</option><option value='Fail'>Fail</option></select></td>"; for ($n = 3; $n <= 12; $n++) { print "<td><select name=\"add_$nby$n\"><option value='".$row["$nby$n"]."'>".$row["$nby$n"]."</option><option value='Pass'>Pass</option><option value='Fail'>Fail</option></select></td>"; } print "</tr>"; } while ($row = mysql_fetch_array($query)); } print "</table>"; print "<input type='submit' name='add_class_scores' value='Add Scores' /> <input type='hidden' value='".$name."' name='student_name' /> </form>"; exit(); } print "<h2>Please select the class you would like to add results for</h2>"; $query = mysql_query("SELECT * FROM classes"); print "<form method='post'> <table> <tr><td>Student</td><td> <select name='add_byclass' onchange='this.form.submit();'> <option value='select' selected='selected'>Select</option>"; while ($row = mysql_fetch_array($query)) { print "<option value='".$row["classname"]."'>".$row["classname"]."</option>"; } print "</select></td></tr></table></form>"; // this section is for showing completed test results, by class or by individual } else if ($_GET["show"] == "completetests") { print "<p>Please select by what you would like to view scores</p> <p><a href='admin.php?show=completetests&type=class'>By Class</a><br /><a href='admin.php?show=completetests&type=individual'>By Individual</a></p>"; if ($_GET["show"] == "completetests" && $_GET["type"] == "class") { if ($_GET["show"] == "completetests" && $_GET["type"] == "class" && $_POST["results_byclass"]) { $class = $_POST["results_byclass"]; $query = mysql_query("SELECT * FROM students WHERE classname = '$class'"); if ($row = mysql_fetch_array($query)) { print "<h2>Viewing Results by Class</h2> <table id='results' border='1'> <th>Name</th><th>Class</th><th>2 x 2</th><th>3 x 3</th><th>4 x 4</th><th>5 x 5</th><th>6 x 6</th><th>7 x 7</th><th>8 x 8</th><th>9 x 9</th> <th>10 x 10</th><th>11 x 11</th><th>12 x 12</th>"; do { print "<tr><td>".$row["student_name"]."</td><td>".$row["classname"]."</td><td class='$class'>".$row["2by2"]."</td> <td class='$class'>".$row["3by3"]."</td><td class='$class'>".$row["4by4"]."</td><td class='$class'>".$row["5by5"]."</td> <td class='$class'>".$row["6by6"]."</td><td class='$class'>".$row["7by7"]."</td><td class='$class'>".$row["8by8"]."</td> <td class='$class'>".$row["9by9"]."</td><td class='$class'>".$row["10by10"]."</td><td class='$class'>".$row["11by11"]."</td> <td class='$class'>".$row["12by12"]."</td>"; } while ($row = mysql_fetch_array($query)); print "</table>"; } exit(); } $query = mysql_query("SELECT * FROM classes"); print "<p>Please select which class you would like to see the results for</p> <form method='post'> <table style='width:300px'> <tr><td style='width:30px;'>Class</td><td> <select name='results_byclass' onchange='this.form.submit();'> <option value='select' selected='selected'>Select</option>"; while ($row = mysql_fetch_array($query)) { print "<option value='".$row["classname"]."'>".$row["classname"]."</option>"; } print "</select></td></tr> </table> </form>"; } else if ($_GET["show"] == "completetests" && $_GET["type"] == "individual") { if ($_GET["show"] == "completetests" && $_GET["type"] == "individual" && $_POST["results_byind"]) { $name = $_POST["results_byind"]; $query = mysql_query("SELECT * FROM students WHERE student_name = '$name'"); if ($row = mysql_fetch_array($query)) { print "<h2>Viewing Results by Student</h2> <table id='results' border='1'> <th>Name</th><th>Class</th><th>2 x 2</th><th>3 x 3</th><th>4 x 4</th><th>5 x 5</th><th>6 x 6</th><th>7 x 7</th><th>8 x 8</th><th>9 x 9</th> <th>10 x 10</th><th>11 x 11</th><th>12 x 12</th>"; do { for ($n = 2; $n <= 12; $n++) { if ($row["$nby$n"] == "Not Taken") $class = "amber"; if ($row["$nby$n"] == "Fail") $class = "red"; if ($row["$nby$n"] == "Pass") $class = "green"; } print "<tr><td>".$row["student_name"]."</td><td>".$row["classname"]."</td><td class='$class'>".$row["2by2"]."</td> <td class='$class'>".$row["3by3"]."</td><td class='$class'>".$row["4by4"]."</td><td class='$class'>".$row["5by5"]."</td> <td class='$class'>".$row["6by6"]."</td><td class='$class'>".$row["7by7"]."</td><td class='$class'>".$row["8by8"]."</td> <td class='$class'>".$row["9by9"]."</td><td class='$class'>".$row["10by10"]."</td><td class='$class'>".$row["11by11"]."</td> <td class='$class'>".$row["12by12"]."</td>"; } while ($row = mysql_fetch_array($query)); print "</table>"; exit(); } } $query = mysql_query("SELECT * FROM students"); print "<form method='post'> <table> <tr><td>Student</td><td> <select name='results_byind' onchange='this.form.submit();'> <option value='select' selected='selected'>Select</option>"; while ($row = mysql_fetch_array($query)) { print "<option value='".$row["student_name"]."'>".$row["student_name"]."</option>"; } print "</select></td></tr> </table></form>"; } } ?> </body> </html>[/code] This is the addscores file: [code]<? /********************************************\ * * * class test administation * * copyright 2005 Phil Pedlar * * * \********************************************/ require_once("dbconnect.php"); $_2by2 = $_POST["add_2by2"]; $_3by3 = $_POST["add_3"]; $_4by4 = $_POST["add_4"]; $_5by5 = $_POST["add_5"]; $_6by6 = $_POST["add_6"]; $_7by7 = $_POST["add_7"]; $_8by8 = $_POST["add_8"]; $_9by9 = $_POST["add_9"]; $_10by10 = $_POST["add_10"]; $_11by11 = $_POST["add_11"]; $_12by12 = $_POST["add_12"]; $student = $_POST["student_name"]; $query = "UPDATE students SET 2by2 = '$_2by2', 3by3 = '$_3by3', 4by4 = '$_4by4', 5by5 = '$_5by5', 6by6 = '$_6by6', 7by7 = '$_7by7', 8by8 = '$_8by8', 9by9 = '$_9by9', 10by10 = '$_10by10', 11by11 = '$_11by11', 12by12 = '$_12by12' WHERE student_name = '$student'"; mysql_query($query); print "<p>Added scores to database</p> <p><a href='admin.php'>back</p>"; ?>[/code] and this is the index files: [code]<?php require_once("dbconnect.php"); session_start(); if ($_POST) { $user = $_POST["username"]; $pass = md5($_POST["password"]); $query = mysql_query("SELECT * FROM login WHERE username = '$user' AND password = '$pass'")or die(mysql_error()); $row = mysql_fetch_array($query); if ($user == $row["username"] && $pass = $row["password"]) { session_register('username'); $_SESSION['username'] = $user; header ("location: admin.php"); } else { header ("location: index.php"); } } ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head profile="http://gmpg.org/xfn/11"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Multiplication Administration</title> <meta name="generator" content="WordPress 1.5.2" /> <!-- leave this for stats please --> <style type="text/css" media="screen"> </style> <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://west4me.com/wordpress/?feed=rss2" /> <link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="http://west4me.com/wordpress/?feed=atom" /> <link rel="pingback" href="http://west4me.com/wordpress/xmlrpc.php" /> <link rel='archives' title='October 2005' href='http://west4me.com/wordpress/?m=200510' /> <link rel='archives' title='September 2005' href='http://west4me.com/wordpress/?m=200509' /> <link href="style.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- .style2 {font-size: 16px; } .style3 {font-size: 16px; color: #676E04; } --> </style> </head> <body> <div id="rap"> <div id="header"> <ul id="topnav"> <li><a href="http://west4me.com/moodle" id="navHome" title="Posted Recently" accesskey="h">Home</a></li> <li><a href="http://west4me.com/cal" id="navHome" title="Posted Recently" accesskey="c">Calendar</a></li> <li><a href="http://west4me.com/story2" id="navHome" title="Posted Recently" accesskey="s">Stories</a></li> <li><a href="http://west4me.com/bookmarks" id="navHome" title="Posted Recently" accesskey="b">Bookmarks</a></li> <li><a href="http://west4me.com/wordpress" id="navHome" title="Posted Recently" accesskey="w">Blog</a></li> <li><a href="http://west4me.com/webcollab/index.php" id="navHome" title="Posted Recently" accesskey="p">Writing Progress</a></li> <li><a href="http://west4me.com/kidscms/index.php" id="navHome" title="Posted Recently" accesskey="f">Student Pages</a></li> <li><a href="http://west4me.com/daily/name.php" id="navHome" title="Posted Recently" accesskey="f">Name Draw</a></li> <li><a href="http://west4me.com/daily/job2.php" id="navHome" title="Posted Recently" accesskey="f">Jobs</a></li> <li><a href="http://west4me.com/daily/lunch.php" id="navHome" title="Posted Recently" accesskey="f">Lunch Choice</a></li> <li><a href="http://west4me.com/daily/" id="navHome" title="Posted Recently" accesskey="f">Daily</a></li> </ul> <h1><a href="http://west4me.com/daily" title=""></a></h1> <div id="desc">Classroom Schedule</div> </div> <div id="main"> <div id="content"> <div class="post"> <div class="post-info"><h2 class="post-title">Welcome to another wonderful day!</a></h2> <p>Make sure you take care of all your morning tasks before the bell rings.</p> </div> <div class="post-content"> <form name='login' method='POST'> <table style='width:300px;'> <tr><td>Username</td><td><input type='text' name='username' /></td></tr> <tr><td>Password</td><td><input type='password' name='password' /></td></tr> <tr><td></td><td><input type='submit' value='Login' /></td></tr> </table> <div id="content"></div> <p> </p> </div> </div> <p align="center"></p> </div> <p id="footer"><a href="http://www.west4me.com/moodle" title="Cunningham">Mr. Cunningham's Classroom</a></p></div> </div> </body> </html>[/code] Please any help would be appreciated.
-
I had a site built for me and I had it working but something happend to the database that I was using. I either did something or something else happend. The error I get when I try to login is this: [code]Can't find file: 'classes.MYI' (errno: 2)[/code] any ideas of how to fix that? I also get that error when I view through phpmyadmin. I have a feeling I need to rebuild the database but I have no idea of how to write the .sql file. I can't reach the guy who built it. I l will list the code from all of the pages that the site uses, could someone take a look at it and write a new .sql file for me? I would be willing to make a donation for help. This is the dbconnect file: [code]<? $location = "localhost"; $user = ""; $password = ""; $db = ""; $conn = mysql_connect($location, $user, $password) or die("Could not connect to MySQL"); $db = mysql_select_db($db) or die("Could not select database".mysql_error()); ?>[/code] This is the admin file: [code]<?php /********************************************\ * * * class test administation * * copyright 2005 Phil Pedlar * * * \********************************************/ session_start(); if (!$_SESSION['username']) { header ("location: index.php"); } include ("dbconnect.php"); require_once("dbconnect.php"); ?> <html> <head> <title>Test Admin</title> <style> body { font: 12px verdana; } table { font: 12px verdana; } h2 { font: 16px verdana; font-weight: bold; } #results td { padding-left: 10px; padding-right: 10px; } #results td { padding-left: 5px; padding-right: 5px; } </style> </head> <body> <span>| <a href='admin.php?add=class'>Add Class</a> | <a href='admin.php?add=student'>Add Student</a> | <a href='admin.php?add=scores'>Add Scores</a> | <a href='admin.php?show=completetests'>View Complete Tests</a> |</span> <p /> <? //this section is for adding a class if ($_GET["add"] == "class") { if ($_GET["add"] == "class" && $_POST["classname"]) { $classname = $_POST["classname"]; $query = mysql_query("INSERT INTO classes (`classid`, `classname`) VALUES ('', '$classname')"); print "<p>Class $classname was succesfully added to the the classes list</p>"; exit(); } print "<p>Please type in the box below which classname you would like to add to the list</p>"; print "<form method='post'> <table style='width:300px;'> <tr><td>Classname</td><td><input type='text' name='classname' /></td></tr> <tr><td></td><td><input type='submit' value='Add Class' /></td></tr> </table> </form>"; //this section is for adding a student } else if ($_GET["add"] == "student") { if ($_GET["add"] == "student" && $_POST["student_classname"] == "select") { print "<p>You did not select a class for this student</p> <p><a href='admin.php?add=student'>back</a></p>"; exit(); } else if ($_GET["add"] == "student" && $_POST["student_studentname"] && $_POST["student_classname"]) { $studentname = $_POST["student_studentname"]; $classname = $_POST["student_classname"]; $query = mysql_query("INSERT INTO students (`studentid`, `student_name`, `classname`) VALUES ('', '$studentname', '$classname')"); print "<p>Succsfully added student: $studentname to class: $classname</p>"; exit(); } print "<p>Please type the name of the student you would like to add in the box and select the classname that they belong to.</p>"; print "<form method='post'> <table style='width:300px;'> <tr><td>Student Name:</td><td><input type='text' name='student_studentname' /></td></tr> <tr><td>Student Class:</td><td> <select name='student_classname'> <option value='select' selected='selected'>Select</option>"; $query = mysql_query("SELECT * FROM classes"); while ($row = mysql_fetch_array($query)) { print "<option value='".$row["classname"]."'>".$row["classname"]."</option>"; } print " </select> </td></tr> <tr><td></td><td><input type='submit' value='Add Student' /></td></tr> </table> </form>"; } else if ($_GET["add"] == "scores") { print "<p>Please select by what you would like to add scores</p> <p><a href='admin.php?add=scores&type=individual'>By Individual</a></p>"; if ($_GET["add"] == "scores" && $_POST["add_byclass"]) { print "<h2>Please select the student you would like to add results for</h2>"; $class = $_POST["add_byclass"]; $query = mysql_query("SELECT * FROM students WHERE classname = '$class'"); print "<form method='post'> <table> <tr><td>Student</td><td> <select name='add_byname' onchange='this.form.submit();'> <option value='select' selected='selected'>Select</option>"; while ($row = mysql_fetch_array($query)) { print "<option value='".$row["student_name"]."'>".$row["student_name"]."</option>"; } print "<input type='hidden' name='student_name' value='".$row["student_name"]."' /> </table> </form>"; exit(); } if ($_GET["add"] == "scores" && $_POST["add_byname"]) { $name = $_POST["add_byname"]; $query = mysql_query("SELECT * FROM students WHERE student_name = '$name' ORDER BY student_name"); if ($row = mysql_fetch_array($query)) { print "<form method='post' action='addscores.php'> <table id='addscore' border='1'> <tr><th>Name</th><th>Class</th><th>2 x 2</th><th>3 x 3</th><th>4 x 4</th><th>5 x 5</th><th>6 x 6</th><th>7 x 7</th><th>8 x 8</th><th>9 x 9</th> <th>10 x 10</th><th>11 x 11</th><th>12 x 12</th></tr>"; do { print "<td style='width:50px;'>".$row["student_name"]."</td><td style='width:50px;'>".$row["classname"]."</td>"; print "<td><select name='add_2by2'><option value='".$row["2by2"]."'>".$row["2by2"]."</option><option value='Pass'>Pass</option><option value='Fail'>Fail</option></select></td>"; for ($n = 3; $n <= 12; $n++) { print "<td><select name=\"add_$nby$n\"><option value='".$row["$nby$n"]."'>".$row["$nby$n"]."</option><option value='Pass'>Pass</option><option value='Fail'>Fail</option></select></td>"; } print "</tr>"; } while ($row = mysql_fetch_array($query)); } print "</table>"; print "<input type='submit' name='add_class_scores' value='Add Scores' /> <input type='hidden' value='".$name."' name='student_name' /> </form>"; exit(); } print "<h2>Please select the class you would like to add results for</h2>"; $query = mysql_query("SELECT * FROM classes"); print "<form method='post'> <table> <tr><td>Student</td><td> <select name='add_byclass' onchange='this.form.submit();'> <option value='select' selected='selected'>Select</option>"; while ($row = mysql_fetch_array($query)) { print "<option value='".$row["classname"]."'>".$row["classname"]."</option>"; } print "</select></td></tr></table></form>"; // this section is for showing completed test results, by class or by individual } else if ($_GET["show"] == "completetests") { print "<p>Please select by what you would like to view scores</p> <p><a href='admin.php?show=completetests&type=class'>By Class</a><br /><a href='admin.php?show=completetests&type=individual'>By Individual</a></p>"; if ($_GET["show"] == "completetests" && $_GET["type"] == "class") { if ($_GET["show"] == "completetests" && $_GET["type"] == "class" && $_POST["results_byclass"]) { $class = $_POST["results_byclass"]; $query = mysql_query("SELECT * FROM students WHERE classname = '$class'"); if ($row = mysql_fetch_array($query)) { print "<h2>Viewing Results by Class</h2> <table id='results' border='1'> <th>Name</th><th>Class</th><th>2 x 2</th><th>3 x 3</th><th>4 x 4</th><th>5 x 5</th><th>6 x 6</th><th>7 x 7</th><th>8 x 8</th><th>9 x 9</th> <th>10 x 10</th><th>11 x 11</th><th>12 x 12</th>"; do { print "<tr><td>".$row["student_name"]."</td><td>".$row["classname"]."</td><td class='$class'>".$row["2by2"]."</td> <td class='$class'>".$row["3by3"]."</td><td class='$class'>".$row["4by4"]."</td><td class='$class'>".$row["5by5"]."</td> <td class='$class'>".$row["6by6"]."</td><td class='$class'>".$row["7by7"]."</td><td class='$class'>".$row["8by8"]."</td> <td class='$class'>".$row["9by9"]."</td><td class='$class'>".$row["10by10"]."</td><td class='$class'>".$row["11by11"]."</td> <td class='$class'>".$row["12by12"]."</td>"; } while ($row = mysql_fetch_array($query)); print "</table>"; } exit(); } $query = mysql_query("SELECT * FROM classes"); print "<p>Please select which class you would like to see the results for</p> <form method='post'> <table style='width:300px'> <tr><td style='width:30px;'>Class</td><td> <select name='results_byclass' onchange='this.form.submit();'> <option value='select' selected='selected'>Select</option>"; while ($row = mysql_fetch_array($query)) { print "<option value='".$row["classname"]."'>".$row["classname"]."</option>"; } print "</select></td></tr> </table> </form>"; } else if ($_GET["show"] == "completetests" && $_GET["type"] == "individual") { if ($_GET["show"] == "completetests" && $_GET["type"] == "individual" && $_POST["results_byind"]) { $name = $_POST["results_byind"]; $query = mysql_query("SELECT * FROM students WHERE student_name = '$name'"); if ($row = mysql_fetch_array($query)) { print "<h2>Viewing Results by Student</h2> <table id='results' border='1'> <th>Name</th><th>Class</th><th>2 x 2</th><th>3 x 3</th><th>4 x 4</th><th>5 x 5</th><th>6 x 6</th><th>7 x 7</th><th>8 x 8</th><th>9 x 9</th> <th>10 x 10</th><th>11 x 11</th><th>12 x 12</th>"; do { for ($n = 2; $n <= 12; $n++) { if ($row["$nby$n"] == "Not Taken") $class = "amber"; if ($row["$nby$n"] == "Fail") $class = "red"; if ($row["$nby$n"] == "Pass") $class = "green"; } print "<tr><td>".$row["student_name"]."</td><td>".$row["classname"]."</td><td class='$class'>".$row["2by2"]."</td> <td class='$class'>".$row["3by3"]."</td><td class='$class'>".$row["4by4"]."</td><td class='$class'>".$row["5by5"]."</td> <td class='$class'>".$row["6by6"]."</td><td class='$class'>".$row["7by7"]."</td><td class='$class'>".$row["8by8"]."</td> <td class='$class'>".$row["9by9"]."</td><td class='$class'>".$row["10by10"]."</td><td class='$class'>".$row["11by11"]."</td> <td class='$class'>".$row["12by12"]."</td>"; } while ($row = mysql_fetch_array($query)); print "</table>"; exit(); } } $query = mysql_query("SELECT * FROM students"); print "<form method='post'> <table> <tr><td>Student</td><td> <select name='results_byind' onchange='this.form.submit();'> <option value='select' selected='selected'>Select</option>"; while ($row = mysql_fetch_array($query)) { print "<option value='".$row["student_name"]."'>".$row["student_name"]."</option>"; } print "</select></td></tr> </table></form>"; } } ?> </body> </html>[/code] This is the addscores file: [code]<? /********************************************\ * * * class test administation * * copyright 2005 Phil Pedlar * * * \********************************************/ require_once("dbconnect.php"); $_2by2 = $_POST["add_2by2"]; $_3by3 = $_POST["add_3"]; $_4by4 = $_POST["add_4"]; $_5by5 = $_POST["add_5"]; $_6by6 = $_POST["add_6"]; $_7by7 = $_POST["add_7"]; $_8by8 = $_POST["add_8"]; $_9by9 = $_POST["add_9"]; $_10by10 = $_POST["add_10"]; $_11by11 = $_POST["add_11"]; $_12by12 = $_POST["add_12"]; $student = $_POST["student_name"]; $query = "UPDATE students SET 2by2 = '$_2by2', 3by3 = '$_3by3', 4by4 = '$_4by4', 5by5 = '$_5by5', 6by6 = '$_6by6', 7by7 = '$_7by7', 8by8 = '$_8by8', 9by9 = '$_9by9', 10by10 = '$_10by10', 11by11 = '$_11by11', 12by12 = '$_12by12' WHERE student_name = '$student'"; mysql_query($query); print "<p>Added scores to database</p> <p><a href='admin.php'>back</p>"; ?>[/code] and this is the index files: [code]<?php require_once("dbconnect.php"); session_start(); if ($_POST) { $user = $_POST["username"]; $pass = md5($_POST["password"]); $query = mysql_query("SELECT * FROM login WHERE username = '$user' AND password = '$pass'")or die(mysql_error()); $row = mysql_fetch_array($query); if ($user == $row["username"] && $pass = $row["password"]) { session_register('username'); $_SESSION['username'] = $user; header ("location: admin.php"); } else { header ("location: index.php"); } } ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head profile="http://gmpg.org/xfn/11"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Multiplication Administration</title> <meta name="generator" content="WordPress 1.5.2" /> <!-- leave this for stats please --> <style type="text/css" media="screen"> </style> <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://west4me.com/wordpress/?feed=rss2" /> <link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="http://west4me.com/wordpress/?feed=atom" /> <link rel="pingback" href="http://west4me.com/wordpress/xmlrpc.php" /> <link rel='archives' title='October 2005' href='http://west4me.com/wordpress/?m=200510' /> <link rel='archives' title='September 2005' href='http://west4me.com/wordpress/?m=200509' /> <link href="style.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- .style2 {font-size: 16px; } .style3 {font-size: 16px; color: #676E04; } --> </style> </head> <body> <div id="rap"> <div id="header"> <ul id="topnav"> <li><a href="http://west4me.com/moodle" id="navHome" title="Posted Recently" accesskey="h">Home</a></li> <li><a href="http://west4me.com/cal" id="navHome" title="Posted Recently" accesskey="c">Calendar</a></li> <li><a href="http://west4me.com/story2" id="navHome" title="Posted Recently" accesskey="s">Stories</a></li> <li><a href="http://west4me.com/bookmarks" id="navHome" title="Posted Recently" accesskey="b">Bookmarks</a></li> <li><a href="http://west4me.com/wordpress" id="navHome" title="Posted Recently" accesskey="w">Blog</a></li> <li><a href="http://west4me.com/webcollab/index.php" id="navHome" title="Posted Recently" accesskey="p">Writing Progress</a></li> <li><a href="http://west4me.com/kidscms/index.php" id="navHome" title="Posted Recently" accesskey="f">Student Pages</a></li> <li><a href="http://west4me.com/daily/name.php" id="navHome" title="Posted Recently" accesskey="f">Name Draw</a></li> <li><a href="http://west4me.com/daily/job2.php" id="navHome" title="Posted Recently" accesskey="f">Jobs</a></li> <li><a href="http://west4me.com/daily/lunch.php" id="navHome" title="Posted Recently" accesskey="f">Lunch Choice</a></li> <li><a href="http://west4me.com/daily/" id="navHome" title="Posted Recently" accesskey="f">Daily</a></li> </ul> <h1><a href="http://west4me.com/daily" title=""></a></h1> <div id="desc">Classroom Schedule</div> </div> <div id="main"> <div id="content"> <div class="post"> <div class="post-info"><h2 class="post-title">Welcome to another wonderful day!</a></h2> <p>Make sure you take care of all your morning tasks before the bell rings.</p> </div> <div class="post-content"> <form name='login' method='POST'> <table style='width:300px;'> <tr><td>Username</td><td><input type='text' name='username' /></td></tr> <tr><td>Password</td><td><input type='password' name='password' /></td></tr> <tr><td></td><td><input type='submit' value='Login' /></td></tr> </table> <div id="content"></div> <p> </p> </div> </div> <p align="center"></p> </div> <p id="footer"><a href="http://www.west4me.com/moodle" title="Cunningham">Mr. Cunningham's Classroom</a></p></div> </div> </body> </html>[/code] Please any help would be appreciated.
-
This is what I [code]Can't find file: 'login.MYI' (errno: 2)[/code]
-
That is a copy/paste error. here is the db-connect [code]<? $location = "localhost"; $user = "******"; $password = "****"; $db = "*****"; $conn = mysql_connect($location, $user, $password) or die("Could not connect to MySQL"); $db = mysql_select_db($db) or die("Could not select database".mysql_error()); ?>[/code] THanks for taking the time to look.
-
I am getting this error [code]Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/west4mec/public_html/multiplication/index.php on line 12 Warning: Cannot modify header information - headers already sent by (output started at /home/west4mec/public_html/multiplication/index.php:12) in /home/west4mec/public_html/multiplication/index.php on line 21[/code] I had someone write this for me awhile ago and I must have messed somehting up. Anyone see an error in the code? I borrowed the layout from WordPress so there is a bunch of extra stuff in there. THis is the index page: [code] <?php require_once("dbconnect.php"); session_start(); if ($_POST) { $user = $_POST["username"]; $pass = md5($_POST["password"]); $query = mysql_query("SELECT * FROM login WHERE username = '$user' AND password = '$pass'"); $row = mysql_fetch_array($query); if ($user == $row["username"] && $pass = $row["password"]) { session_register('username'); $_SESSION['username'] = $user; header ("location: admin.php"); } else { header ("location: index.php"); } } ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head profile="http://gmpg.org/xfn/11"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Multiplication Administration</title> <meta name="generator" content="WordPress 1.5.2" /> <!-- leave this for stats please --> <style type="text/css" media="screen"> </style> <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://west4me.com/wordpress/?feed=rss2" /> <link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="http://west4me.com/wordpress/?feed=atom" /> <link rel="pingback" href="http://west4me.com/wordpress/xmlrpc.php" /> <link rel='archives' title='October 2005' href='http://west4me.com/wordpress/?m=200510' /> <link rel='archives' title='September 2005' href='http://west4me.com/wordpress/?m=200509' /> <link href="style.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- .style2 {font-size: 16px; } .style3 {font-size: 16px; color: #676E04; } --> </style> </head> <body> <div id="rap"> <div id="header"> <ul id="topnav"> <li><a href="http://west4me.com/moodle" id="navHome" title="Posted Recently" accesskey="h">Home</a></li> <li><a href="http://west4me.com/cal" id="navHome" title="Posted Recently" accesskey="c">Calendar</a></li> <li><a href="http://west4me.com/story2" id="navHome" title="Posted Recently" accesskey="s">Stories</a></li> <li><a href="http://west4me.com/bookmarks" id="navHome" title="Posted Recently" accesskey="b">Bookmarks</a></li> <li><a href="http://west4me.com/wordpress" id="navHome" title="Posted Recently" accesskey="w">Blog</a></li> <li><a href="http://west4me.com/webcollab/index.php" id="navHome" title="Posted Recently" accesskey="p">Writing Progress</a></li> <li><a href="http://west4me.com/kidscms/index.php" id="navHome" title="Posted Recently" accesskey="f">Student Pages</a></li> <li><a href="http://west4me.com/daily/name.php" id="navHome" title="Posted Recently" accesskey="f">Name Draw</a></li> <li><a href="http://west4me.com/daily/job2.php" id="navHome" title="Posted Recently" accesskey="f">Jobs</a></li> <li><a href="http://west4me.com/daily/lunch.php" id="navHome" title="Posted Recently" accesskey="f">Lunch Choice</a></li> <li><a href="http://west4me.com/daily/" id="navHome" title="Posted Recently" accesskey="f">Daily</a></li> </ul> <h1><a href="http://west4me.com/daily" title=""></a></h1> <div id="desc">Classroom Schedule</div> </div> <div id="main"> <div id="content"> <div class="post"> <div class="post-info"><h2 class="post-title">Welcome to another wonderful day!</a></h2> <p>Make sure you take care of all your morning tasks before the bell rings.</p> </div> <div class="post-content"> <form name='login' method='POST'> <table style='width:300px;'> <tr><td>Username</td><td><input type='text' name='username' /></td></tr> <tr><td>Password</td><td><input type='password' name='password' /></td></tr> <tr><td></td><td><input type='submit' value='Login' /></td></tr> </table> <div id="content"></div> <p> </p> </div> </div> <p align="center"></p> </div> <p id="footer"><a href="http://www.west4me.com/moodle" title="Cunningham">Mr. Cunningham's Classroom</a></p></div> </div> </body> </html>[/code] and this is the admin page: [code]<?php /********************************************\ * * * class test administation * * copyright 2005 Phil Pedlar * * * \********************************************/ session_start(); if (!$_SESSION['username']) { header ("location: index.php"); } include ("dbconnect.php"); require_once("dbconnect.php"); function print_footer() { print "<div class='page-content'> <div colspan='5' class='post-footer'> </div> </div> </div> </div> </div> <p align='center'></p> </div> <p id='footer'><a href='http://www.west4me.com/moodle' title='Cunningham'>Mr. Cunninghams Classroom</a></p></div> </div>"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head profile="http://gmpg.org/xfn/11"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Multiplication Administration</title> <meta name="generator" content="WordPress 1.5.2" /> <!-- leave this for stats please --> <style type="text/css" media="screen"> </style> <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://west4me.com/wordpress/?feed=rss2" /> <link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="http://west4me.com/wordpress/?feed=atom" /> <link rel="pingback" href="http://west4me.com/wordpress/xmlrpc.php" /> <link rel='archives' title='October 2005' href='http://west4me.com/wordpress/?m=200510' /> <link rel='archives' title='September 2005' href='http://west4me.com/wordpress/?m=200509' /> <link href="http://west4me.com/multiplication/style.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- .style2 {font-size: 16px; } .style3 {font-size: 16px; color: #676E04; } --> #scores { border: 1px solid black; background:#ffffff; text-align:center; padding-left: 10px; padding-right: 10px;} #scores td { border: 1px solid black; background:#F3F6ED; padding-left: 3px; padding-right: 3px; width: 725px;} </style> </head> <body> <div id="rap"> <div id="header"> <ul id="topnav"> <li><a href="http://west4me.com/moodle" id="navHome" title="Posted Recently" accesskey="h">Home</a></li> <li><a href="http://west4me.com/cal" id="navHome" title="Posted Recently" accesskey="c">Calendar</a></li> <li><a href="http://west4me.com/story2" id="navHome" title="Posted Recently" accesskey="s">Stories</a></li> <li><a href="http://west4me.com/bookmarks" id="navHome" title="Posted Recently" accesskey="b">Bookmarks</a></li> <li><a href="http://west4me.com/wordpress" id="navHome" title="Posted Recently" accesskey="w">Blog</a></li> <li><a href="http://west4me.com/webcollab/index.php" id="navHome" title="Posted Recently" accesskey="p">Writing Progress</a></li> <li><a href="http://west4me.com/kidscms/index.php" id="navHome" title="Posted Recently" accesskey="f">Student Pages</a></li> <li><a href="http://west4me.com/daily/name.php" id="navHome" title="Posted Recently" accesskey="f">Name Draw</a></li> <li><a href="http://west4me.com/daily/job2.php" id="navHome" title="Posted Recently" accesskey="f">Jobs</a></li> <li><a href="http://west4me.com/daily/lunch.php" id="navHome" title="Posted Recently" accesskey="f">Lunch Choice</a></li> <li><a href="http://west4me.com/daily/" id="navHome" title="Posted Recently" accesskey="f">Daily</a></li> </ul> <h1><a href="http://west4me.com/daily" title=""></a></h1> <div id="desc">Multiplication Tests</div> </div> <div id="main"> <div id="content"> <div class="post"> <div class="post-info"><h2 class="post-title">Multiplication Test Administration</a></h2> <p></p> </div> <div class="post-content"> <div align="center"><span>| <a href='admin.php?add=class'>Add Class</a> | <a href='admin.php?add=student'>Add Student</a> | <a href='admin.php?add=scores'>Add Scores</a> | <a href='admin.php?show=completetests'>View Complete Tests</a> |</span></div> <? print "<div class='post-content'>"; //this section is for adding a class if ($_GET["add"] == "class") { if ($_GET["add"] == "class" && $_POST["classname"]) { $classname = $_POST["classname"]; $query = mysql_query("INSERT INTO classes (`classid`, `classname`) VALUES ('', '$classname')"); print "<p>Class $classname was succesfully added to the the classes list</p>"; exit(); } print "<div class='post-title'><p>Please type in the box below which classname you would like to add to the list</p></div>"; print "<form method='post'> <table style='width:300px;'> <tr><td>Classname</td><td><input type='text' name='classname' /></td></tr> <tr><td></td><td><input type='submit' value='Add Class' /></td></tr> </table> </form>"; //this section is for adding a student } else if ($_GET["add"] == "student") { if ($_GET["add"] == "student" && $_POST["student_classname"] == "select") { print "<p>You did not select a class for this student</p> <p><a href='admin.php?add=student'>back</a></p>"; exit(); } else if ($_GET["add"] == "student" && $_POST["student_studentname"] && $_POST["student_classname"]) { $studentname = $_POST["student_studentname"]; $classname = $_POST["student_classname"]; $query = mysql_query("INSERT INTO students (`studentid`, `student_name`, `classname`) VALUES ('', '$studentname', '$classname')"); print "<p>Succsfully added student: $studentname to class: $classname</p>"; exit(); } print "<p>Please type the name of the student you would like to add in the box and select the classname that they belong to.</p>"; print "<form method='post'> <table style='width:300px;'> <tr><td>Student Name:</td><td><input type='text' name='student_studentname' /></td></tr> <tr><td>Student Class:</td><td> <select name='student_classname'> <option value='select' selected='selected'>Select</option>"; $query = mysql_query("SELECT * FROM classes"); while ($row = mysql_fetch_array($query)) { print "<option value='".$row["classname"]."'>".$row["classname"]."</option>"; } print " </select> </td></tr> <tr><td></td><td><input type='submit' value='Add Student' /></td></tr> </table> </form>"; } else if ($_GET["add"] == "scores") { print "<h2>Please select the class you would like to add results for</h2>"; $query = mysql_query("SELECT * FROM classes"); print "<form method='post'> <table> <tr><td>Class</td><td> <select name='add_byclass' onchange='this.form.submit();'> <option value='select' selected='selected'>Select</option>"; while ($row = mysql_fetch_array($query)) { print "<option value='".$row["classname"]."'>".$row["classname"]."</option>"; } print "</select></td></tr></table></form>"; if ($_GET["add"] == "scores" && $_POST["add_byclass"]) { print "<h2>Please select the student you would like to add results for</h2>"; $class = $_POST["add_byclass"]; $query = mysql_query("SELECT * FROM students WHERE classname = '$class'"); print "<form method='post'> <table> <tr><td>Student</td><td> <select name='add_byname' onchange='this.form.submit();'> <option value='select' selected='selected'>Select</option>"; while ($row = mysql_fetch_array($query)) { print "<option value='".$row["student_name"]."'>".$row["student_name"]."</option>"; } print "<input type='hidden' name='student_name' value='".$row["student_name"]."' /> </table> </form>"; print_footer(); exit(); } if ($_GET["add"] == "scores" && $_POST["add_byname"]) { $name = $_POST["add_byname"]; $query = mysql_query("SELECT * FROM students WHERE student_name = '$name' ORDER BY student_name"); if ($row = mysql_fetch_array($query)) { print "<form method='post' action='addscores.php'> <table width='100%' id='scores'> <tr><th>Name</th><th>Class</th><th>2 x 2</th><th>3 x 3</th><th>4 x 4</th><th>5 x 5</th><th>6 x 6</th><th>7 x 7</th><th>8 x 8</th><th>9 x 9</th> <th>10 x 10</th><th>11 x 11</th><th>12 x 12</th></tr>"; do { print "<td style='width:50px;'>".$row["student_name"]."</td><td style='width:50px;'>".$row["classname"]."</td>"; print "<td><select name='add_2by2'><option value='".$row["2by2"]."'>".$row["2by2"]."</option><option value='Pass'>Pass</option><option value='Fail'>Fail</option></select></td>"; for ($n = 3; $n <= 12; $n++) { print "<td><select name=\"add_$nby$n\"><option value='".$row["$nby$n"]."'>".$row["$nby$n"]."</option><option value='Pass'>Pass</option><option value='Fail'>Fail</option></select></td>"; } print "</tr>"; } while ($row = mysql_fetch_array($query)); } print "</table>"; print "<input type='submit' name='add_class_scores' value='Add Scores' /> <input type='hidden' value='".$name."' name='student_name' /> </form>"; print_footer(); exit(); } // this section is for showing completed test results, by class or by individual } else if ($_GET["show"] == "completetests") { print "<div class='post-title'><p>Please select by what you would like to view scores</p></div> <p><a href='admin.php?show=completetests&type=class'>By Class</a><br /><a href='admin.php?show=completetests&type=individual'>By Individual</a></p>"; if ($_GET["show"] == "completetests" && $_GET["type"] == "class") { if ($_GET["show"] == "completetests" && $_GET["type"] == "class" && $_POST["results_byclass"]) { $class = $_POST["results_byclass"]; $query = mysql_query("SELECT * FROM students WHERE classname = '$class'"); if ($row = mysql_fetch_array($query)) { print "<h2>Viewing Results by Class</h2> <table width='100%' id='scores'> <th>Name</th><th>Class</th><th>2 x 2</th><th>3 x 3</th><th>4 x 4</th><th>5 x 5</th><th>6 x 6</th><th>7 x 7</th><th>8 x 8</th><th>9 x 9</th> <th>10 x 10</th><th>11 x 11</th><th>12 x 12</th>"; do { print "<tr><td>".$row["student_name"]."</td><td>".$row["classname"]."</td><td class='$class'>".$row["2by2"]."</td> <td class='$class'>".$row["3by3"]."</td><td class='$class'>".$row["4by4"]."</td><td class='$class'>".$row["5by5"]."</td> <td class='$class'>".$row["6by6"]."</td><td class='$class'>".$row["7by7"]."</td><td class='$class'>".$row["8by8"]."</td> <td class='$class'>".$row["9by9"]."</td><td class='$class'>".$row["10by10"]."</td><td class='$class'>".$row["11by11"]."</td> <td class='$class'>".$row["12by12"]."</td>"; } while ($row = mysql_fetch_array($query)); print "</table>"; print_footer(); } exit(); } $query = mysql_query("SELECT * FROM classes"); print "<p>Please select which class you would like to see the results for</p> <form method='post'> <table style='width:300px'> <tr><td style='width:30px;'>Class</td><td> <select name='results_byclass' onchange='this.form.submit();'> <option value='select' selected='selected'>Select</option>"; while ($row = mysql_fetch_array($query)) { print "<option value='".$row["classname"]."'>".$row["classname"]."</option>"; } print "</select></td></tr> </table> </form>"; print_footer(); } else if ($_GET["show"] == "completetests" && $_GET["type"] == "individual") { if ($_GET["show"] == "completetests" && $_GET["type"] == "individual" && $_POST["results_byind"]) { $name = $_POST["results_byind"]; $query = mysql_query("SELECT * FROM students WHERE student_name = '$name'"); if ($row = mysql_fetch_array($query)) { print "<h2>Viewing Results by Student</h2> <table width='100%' id='scores'> <th>Name</th><th>Class</th><th>2 x 2</th><th>3 x 3</th><th>4 x 4</th><th>5 x 5</th><th>6 x 6</th><th>7 x 7</th><th>8 x 8</th><th>9 x 9</th> <th>10 x 10</th><th>11 x 11</th><th>12 x 12</th>"; do { for ($n = 2; $n <= 12; $n++) { if ($row["$nby$n"] == " ") $class = "amber"; if ($row["$nby$n"] == "Fail") $class = "red"; if ($row["$nby$n"] == "Pass") $class = "green"; } print "<tr><td>".$row["student_name"]."</td><td>".$row["classname"]."</td><td class='$class'>".$row["2by2"]."</td> <td class='$class'>".$row["3by3"]."</td><td class='$class'>".$row["4by4"]."</td><td class='$class'>".$row["5by5"]."</td> <td class='$class'>".$row["6by6"]."</td><td class='$class'>".$row["7by7"]."</td><td class='$class'>".$row["8by8"]."</td> <td class='$class'>".$row["9by9"]."</td><td class='$class'>".$row["10by10"]."</td><td class='$class'>".$row["11by11"]."</td> <td class='$class'>".$row["12by12"]."</td>"; } while ($row = mysql_fetch_array($query)); print "</table>"; print_footer(); exit(); } } $query = mysql_query("SELECT * FROM students"); print "<form method='post'> <table> <tr><td>Student</td><td> <select name='results_byind' onchange='this.form.submit();'> <option value='select' selected='selected'>Select</option>"; while ($row = mysql_fetch_array($query)) { print "<option value='".$row["student_name"]."'>".$row["student_name"]."</option>"; } print "</select></td></tr> </table></form>"; } } ?> <div class="page-content"> <div colspan="5" class="post-footer"> </div> </div> </div> </div> </div> <p align="center"></p> </div> <p id="footer"><a href="http://www.west4me.com/moodle" title="Cunningham">Mr. Cunningham's Classroom</a></p></div> </div> </body> </html>[/code]
-
I'm pretty new to coding in html and really have no idea how to do this, I have my students make their luch choice on the computer. I built a page that has a selection box under their name. They make their choise and move on. I would like to be able to submit their choices to a blank page and have their name and the choice they made so I can print it out. Here is the page I have, [a href=\"http://www.west4me.com/daily/lunch.php\" target=\"_blank\"]http://www.west4me.com/daily/lunch.php[/a] Any suggestions? Or can someone point me to a tutorial?
-
I'm an absolute beginner but thought I would try this out. I am a teacher and I wanted to keep track of the multiplication tests that my students pass. I built this page: Multiplication and I wanted to be able to click the radio button for the test that they pass and then hit submit. This would then store the results in a database. I'm figuring this out in steps so what I need help with is: What should the table look like, and what would be the proper sql to fill it. I don't need someone to do it for me I'm just having a difficult time figuring it out. I thought it should look like this: Student1 2 3 4 5 Where Student1 is the row and the numbers are the columns that represent the tests they have passed. I just can't figure out the syntax or how to create it in phpmyadmin. Any help would be greatly appreciated.