Jump to content

gammaman

Members
  • Posts

    138
  • Joined

  • Last visited

    Never

Everything posted by gammaman

  1. The two input boxes are still above the table but they are closer together now. <?php $conn=mysql_connect("localhost","fierm","13183"); if(!$conn){ echo "failed"; }else{ mysql_select_db(fierm); $StudentID = $_POST['id']; session_start(); $_SESSION['admin']['admins']; $_SESSION['admin']['adminpass']; echo '<table border="1">'; echo "<tr><th>CourseID</th><th>CourseName</th><th>Grade</th></tr>"; $result=mysql_query("select CourseID,CourseName,Grade From Rcourse WHERE StudentID='$StudentID'"); $cou=mysql_num_rows($result); if ($cou==0){ echo "Not in Any Courses"; }else{ while ($row=mysql_fetch_array($result)) { $CourseID= $row['CourseID']; $grade = $row['Grade']; $Course=$row['CourseName']; if (($grade) == ""){ $value = "<form action='updateGrades.php' method= 'post'> <input name = 'grd' size='5' type='text' />"; echo "$value"; }else{ $value = "$grade"; } #end if...else echo "<tr><td>$CourseID</td><td>$Course</td><td>$value</td></tr>"; } #end while } #if...else echo "</table>"; echo "</form>"; echo "<b>Return to Student Page</b>"; echo "<a href = \"student.php\">Return to Student Page</a>"; } ?>
  2. I added another record and left that field blank to see what would happen and sure enough now I have to input boxes above the table, which suggests that it is treating the space above the table as a row in the table.
  3. OK I got that part working, now I still need to figure out why I have an input box before the table even starts. It is literally just above the table ouside the border <?php $conn=mysql_connect("localhost","fierm","13183"); if(!$conn){ echo "failed"; }else{ mysql_select_db(fierm); $StudentID = $_POST['id']; session_start(); $_SESSION['admin']['admins']; $_SESSION['admin']['adminpass']; $result=mysql_query("select CourseID,CourseName,Grade From Rcourse WHERE StudentID='$StudentID'"); $cou=mysql_num_rows($result); if ($cou==0){ echo "Not in Any Courses"; }else{ echo '<table border="1">'; echo "<tr><th>CourseID</th><th>CourseName</th><th>Grade</th></tr>"; while ($row=mysql_fetch_array($result)) { $CourseID= $row['CourseID']; $grade = $row['Grade']; $Course=$row['CourseName']; if (($grade) == ""){ $value = "<form action='updateGrades.php' method= 'post'> <input name = 'grd' size='2px' type='text' />"; echo "$value"; echo "</form>"; }else{ $value = "$grade"; } #end if...else echo "<tr><td>$CourseID</td><td>$Course</td><td>$value</td></tr>"; } #end while } #if...else // echo "</form>"; echo "</table>"; echo "<b>Return to Student Page</b>"; echo "<a href = \"student.php\">Return to Student Page</a>"; } ?>
  4. It works now I forgot to reload the page after the last upload. Now the problem is that I have an extra input box above the table in addition to the input box for each row that has no value in the last field. How would I get rid of that box on top and how would I shrink the other input box. Sorry for being a pain, and thanks for everyones help.
  5. Thanks for checking but I did echo the variable and I still get nothing inside that cell.
  6. I tried that and I still do not get any input box at all.
  7. How would I code the following a minimum of six characters with the first being a letter. There must be at least one upper case letter, one and only one number, and one and only one symbol (%,#,~). I have never used regular expressions before so I am clueless as to how to do this.
  8. Is it even possible to put an input box within a table cell. I am trying to do something like this but no luck yet. Here is a portion of the code. while ($row=mysql_fetch_array($result)) { $CourseID= $row['CourseID']; $grade = $row['Grade']; $Course=$row['CourseName']; if (($grade) == " "){ $value = echo '<form action="updateGrades.php" method= "post">' . echo '<input name = "grd" type="text" />'; }else{ $value = "$grade"; } #end if...else echo "<tr><td>$CourseID</td><td>$Course</td><td>$value</td></tr>"; } #end while
  9. It works somewhat now. This is what the table looks like. (Sorry don't know how to display it as an image. CourseID CourseName Grade MTH200 Calculus 3 ENG130 Literature B+ See on the MTH row grade is blank. I want a textbox there and also for each subsequent row that has a blank value. I tried to code it, you can see it in my post above. Just need help with tweaking it to do this task.
  10. I have several problems. First off I have a syntax error because the page loads blank. Secondly I know the code won't work because mine never does. So please help me. I am trying to echo two different rows depedning on weather or not a certain field for that corresponding row is NULL (blank) or not. If it is blank I want a textbox to appear where that spot is so that a value can be passed to another page and I can update the row. If it is not NULL (blank) I want the row echoed normally with all of the values. <?php $conn=mysql_connect("localhost","fierm","13183"); if(!$conn){ echo "failed"; }else{ mysql_select_db(fierm); $StudentID = $_POST['id']; session_start(); $_SESSION['admin']['admins']; $_SESSION['admin']['adminpass']; $result=mysql_query("select CourseID,CourseName,Grade From Rcourse WHERE StudentID='$StudentID'"); $cou=mysql_num_rows($result); if ($cou==0){ echo "Not in Any Courses"; }else{ echo '<table border="1">'; echo "<tr><th>CourseID</th><th>CourseName</th><th>Grade</th></tr>"; while ($row=mysql_fetch_array($result)) { $CourseID= $row['CourseID']; $grade = $row['Grade']; $Course=$row['CourseName']; if (($grade) ! = "NULL"){ $value='<form action="updateGrades.php" method= "post">'; echo "<br />"; '<input name = "grd" type="text" />'; }else{ $value = "$grade"; } #end if...else echo "<tr><td>$CourseID</td><td>$course</td><td>$value</td></tr>"; } #end while } #if...else echo "</form>"; echo "</table>"; echo "<b>Return to Student Page</b>"; echo "<a href = \"student.php\">Return to Student Page</a>"; } ?>
  11. There is a syntax error on this page because it loads blank. Please help me spot it. <?php $Conn=mysql_connect("localhost","fierm","13183"); if(!$Conn){ echo "failed"; } else{ mysql_select_db("fierm"); session_start(); if (!isset($_SESSION['admin']['admins'])) { $_SESSION['admin']=$_POST; $_SESSION['admin']['admins']; $_SESSION['admin']['adminpass']; } if(("{$_SESSION['admin']['admins']}" == "root") && ("{$_SESSION['admin']['adminpass']}"=="pwd123")){ echo "<a href=\"addCourse.php\">Add Courses</a>"; echo "<br />"; echo "<a href=\"addStudent.php\">Add Student</a>"; echo "<br />"; echo "<a href=\"addGrades.php\">Input Grades</a>"; } else{ echo "Invalid Password, Return To Login"; echo "<br/>"; echo "<a href=\"alog.php\">Login</a>"; } } ?>
  12. Yeah I did that already, but now something weird happens, sometimes it works and sometimes it does not, is that even possible?
  13. I have a page set up with sessions like this (checkUser.php) <?php $Conn=mysql_connect("localhost","fierm","13183"); if(!$Conn){ echo "failed"; } else{ mysql_select_db("fierm"); echo "here"; session_start(); if (!isset($_SESSION['checkUser']['user'])) { $_SESSION['checkUser']=$_POST; $_SESSION['checkUser']['user']; $_SESSION['checkUser']['pass']; } echo "{$_SESSION['checkUser']['user']}"; echo "{$_SESSION['checkUser']['pass']}"; $result=mysql_query("select studentID, password FROM Student WHERE studentID='{$_SESSION['checkUser']['user']}' and password='{$_SESSION['checkUser']['pass']}'"); $cou=mysql_num_rows($result); if($cou>0) { echo "Student validated"; echo "<br />"; echo "<a href=\"student.php\">Student Page</a>"; } elseif(("{$_SESSION['checkUser']['user']}"=="root") && ("{$_SESSION['checkUser']['pass']}"=="pwd123")){ echo "<a href=\"admin.php\">Admin Page</a>"; } else{ echo "Invalid Password"; echo "<a href=\"main.php\">Login Again</a>"; } } ?> AND This page receieves it (admin.php) <?php $Conn=mysql_connect("localhost","fierm","13183"); if(!$Conn){ echo "failed"; } else{ mysql_select_db("fierm"); session_start(); $_SESSION['checkUser']['user']; $_SESSION['checkUser']['pass']; echo "<a href=\"addCourse.php\">Add Courses</a>"; echo "<br />"; echo "<a href=\"addStudent.php\">Add Student</a>"; echo "<br />"; echo "<a href=\"addGrades.php\">Input Grades</a>"; } ?> But This page does NOT (student.php) <body> <b>Student Login</b> <?php $Conn=mysql_connect("localhost","fierm","13183"); if(!$Conn){ echo "failed"; } else{ mysql_select_db("fierm"); session_start(); $_SESSION['checkUser']['user']; $_SESSION['checkUser']['pass']; echo "{$_SESSION['checkUser']['user']}"; //Nothing is echoed echo "{$_SESSION['checkUser']['pass']}"; //Nothing is echoed $result=mysql_query("select studentID, password FROM Student WHERE studentID='{$_SESSION['checkUser']['user']}' and password='{$_SESSION['checkUser']['pass']}'"); $cou=mysql_num_rows($result); echo "$cou"; if($cou>0) { echo "<table border=\"1\">"; echo "<b>Registered Courses</b>"; echo "<tr><th>CourseID</th><th>CourseName</th><th>Grade</th></tr>"; $result1=mysql_query("select CourseID,CourseName,StudentID,Grade FROM Rcourse WHERE StudentID='{$_SESSION['checkUser']['user']}'"); $cou=mysql_num_rows($result1); while($row=mysql_fetch_array($result1)) { echo "<tr><td>$row[0]</td><td>$row[1]</td><td>$row[3]</td></tr>\n"; } echo "</table>"; echo "<b>Register For Courses:</b>"; echo "<br />"; echo "<a href=\"regCourse.php\">Register Courses</a>"; echo "<b>Drop a Course:</b>"; echo "<br/>"; echo "<a href=\"dropCourse.php\">Drop a Course</a>"; } } ?>
  14. Here is the latest version of the page <body> <b>Student Login</b> <?php $Conn=mysql_connect("localhost","fierm","13183"); if(!$Conn){ echo "failed"; } else{ mysql_select_db("fierm"); session_start(); if (!isset($_SESSION['student']['user'])) { $_SESSION['student']=$_POST; $_SESSION['student']['user']; $_SESSION['student']['pass']; } $result=mysql_query("select studentID, password FROM Student WHERE studentID='{$_SESSION['student']['user']}' and password='{$_SESSION['student']['pass']}'"); $cou=mysql_num_rows($result); if($cou>0) { echo "<table border=\"1\">"; echo "<b>Registered Courses</b>"; echo "<tr><th>CourseID</th><th>CourseName</th><th>Grade</th></tr>"; $result=mysql_query("select CourseID,CourseName,StudentID,Grade FROM Rcourse WHERE StudentID='{$_SESSION['student']['user']}'"); $cou=mysql_num_rows($result); while($row=mysql_fetch_array($result)) { echo "<tr><td>$row[0]</td><td>$row[1]</td><td>$row[3]</td></tr>\n"; } echo "</table>"; echo "<b>Register For Courses:</b>"; echo "<br />"; echo "<a href=\"regCourse.php\">Register Courses</a>"; echo "<b>Drop a Course:</b>"; echo "<br/>"; echo "<a href=\"dropCourse.php\">Drop a Course</a>"; } else{ echo "Invalid Password"; echo "<a href=\"main.php\">Login Again</a>"; } } ?>
  15. Actually there is still a problem because when I come back to the student page I loose the rows from the table <body> <b>Student Login</b> <?php $Conn=mysql_connect("localhost","fierm","13183"); if(!$Conn){ echo "failed"; } else{ mysql_select_db("fierm"); session_start(); if (!isset($_SESSION['student']['user'])) { $_SESSION['student']=$_POST; $_SESSION['student']['user']; $_SESSION['student']['pass']; } $result=mysql_query("select studentID, password FROM Student WHERE studentID='{$_SESSION['student']['user']}' and password='{$_SESSION['student']['pass']}'"); $cou=mysql_num_rows($result); if($cou>0) { echo "<table border=\"1\">"; echo "<b>Registered Courses</b>"; echo "<tr><th>CourseID</th><th>CourseName</th><th>Grade</th></tr>"; $result=mysql_query("select CourseID,CourseName,StudentID,Grade FROM Rcourse WHERE StudentID='$User'"); $cou=mysql_num_rows($result); while($row=mysql_fetch_array($result)) { echo "<tr><td>$row[0]</td><td>$row[1]</td><td>$row[3]</td></tr>\n"; } echo "</table>"; echo "<b>Register For Courses:</b>"; echo "<br />"; echo "<a href=\"regCourse.php\">Register Courses</a>"; echo "<b>Drop a Course:</b>"; echo "<br/>"; echo "<a href=\"dropCourse.php\">Drop a Course</a>"; } else{ echo "Invalid Password"; echo "<a href=\"main.php\">Login Again</a>"; } Code: (php) <?php $conn=mysql_connect("localhost","fierm","13183"); This code here: $result=mysql_query("select CourseID,CourseName,StudentID,Grade FROM Rcourse WHERE StudentID='$User'"); is messing me up because StudentID should be set to a session but when I tried that I got a blank page.
  16. Got this working now, want to give a special thanks to Darkwater.
  17. This still does not work. Here are the pages again to remind you what I am doing. <body> <b>Student Login</b> <?php $Conn=mysql_connect("localhost","fierm","13183"); if(!$Conn){ echo "failed"; } else{ mysql_select_db("fierm"); $User=$_POST['user']; session_start(); if (!isset($_SESSION['user'])) { $_SESSION['student']=$_POST; $_SESSION['student']['user']; $_SESSION['student']['pass']; } $result=mysql_query("select studentID, password FROM Student WHERE studentID='{$_SESSION['student']['user']}' and password='{$_SESSION['student']['pass']}'"); $cou=mysql_num_rows($result); if($cou>0) { echo "<table border=\"1\">"; echo "<b>Registered Courses</b>"; echo "<tr><th>CourseID</th><th>CourseName</th><th>Grade</th></tr>"; $result=mysql_query("select CourseID,CourseName,StudentID,Grade FROM Rcourse WHERE StudentID='$User'"); $cou=mysql_num_rows($result); while($row=mysql_fetch_array($result)) { echo "<tr><td>$row[0]</td><td>$row[1]</td><td>$row[3]</td></tr>\n"; } echo "</table>"; echo "<b>Register For Courses:</b>"; echo "<br />"; echo "<a href=\"regCourse.php\">Register Courses</a>"; echo "<b>Drop a Course:</b>"; echo "<br/>"; echo "<a href=\"dropCourse.php\">Drop a Course</a>"; } else{ echo "Invalid Password"; echo "<a href=\"main.php\">Login Again</a>"; } <?php $conn=mysql_connect("localhost","fierm","13183"); if(!$conn){ echo "failed"; }else{ mysql_select_db("fierm"); $CourseID = $_GET['ci']; $CourseName = $_GET['cn']; session_start(); $_SESSION['student']['user']; $_SESSION['student']['pass']; $course=mysql_query("select CourseID,CourseName,StudentID,Password FROM Rcourse WHERE CourseID ='$CourseID' AND CourseName='$CourseName' AND StudentID = '{$_SESSION['student']['user']}' AND Password ='{$_SESSION['student']['pass']}'"); $count=mysql_num_rows($course); echo $count; if ($count > 0 ){ echo "Already took or currently taking this course"; echo "<a href = \"student.php?\">Return to Student Page</a>"; }else{ $d = $_SESSION['student']['user']; echo "d = $d"; echo "<br />"; $e = $_SESSION['student']['pass']; echo "e = $e"; echo "<br />"; $conn=mysql_connect("localhost","fierm","13183"); mysql_select_db(fierm); if (!$conn){ echo "not conn"; } else{ echo "here"; } $result=mysql_query("INSERT INTO Rcourse (CourseID,CourseName,StudentID,Password) VALUES ('$CourseID','$CourseName','$d','$e')"); if ($result) { echo '$result set properly.'; } #close the if else { echo "Query is messed up."; } #close the else echo " abc"; } #close the if $count }#closes the !conn ?> When I click the student link which returns you to the first page I posted, it still fails and says invalid user. The session values never change but do they need to get passed into student? Or should it still know what the original values were as if I entered the student page for the first time.
  18. It works now, I had a couple of vars spelled incorrectly. Thanks for the help.
  19. I fixed that now but it still does not fetch any rows.
  20. I dont't know about that because I have another fetch which is assigned to $r.
  21. The table header is displayed but no rows are being fetched.
  22. Now the page displays but I do not get the desired output. I will work on it and let you guys know. Thanks for the help.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.