![]() |
![]() ![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 1 Pomógł: 0 Dołączył: 22.04.2012 Ostrzeżenie: (0%) ![]() ![]() |
Prosze pomozcie
![]() probuje dodac do tabeli sql i wyswietlic wpisane oceny dla studentow w HTML tabeli na stronie. chce dodac oceny razem dla wszystkich studentow po nacisnieci przycisku dodaj oceny (submit) juz sie tak zakrecilam ze nie wiem nawetw ktorym skrypcie powinnam to oceny dodac zeby je pozniej wyswietlic ![]() (wczesniej wybrany jest kierunek i przedmiot ale to jakos latwo poszlo) mam tabele studentID imie nazwisko ocena p1001 anna bak ...... p1002 ela zak ...... <dodaj oceny> itd chce wisac ocene i wyswietlic ja w nowej tabeli studentID imie nazwisko ocena p1001 anna bak 5 p1002 ela zak 3 mam 2 scrypty grades.php (pierwsza tabela) Kod <?php require_once('connect.php'); $dbc = mysqli_connect (HOST, USERNAME, PASSWORD, DATABASE);///why do i need that? ![]() ![]() ![]() ![]() //$mc = $_POST['coursecodes']; $md = $_POST['moduledesc']; $query = 'SELECT s.Student_id, s.S_first_name, s.S_last_name FROM Students s JOIN Modules m ON s.S_Course_code = m.Module_Course_code WHERE m.Module_description = "'.$md.'" ORDER BY s.S_last_name'; // creating query //mysqli_query(connection, query); $result = mysqli_query($dbc, $query); //mysqli_query() returns a result set which can then be processed row by row $result = mysqli_query($dbc, $query); if ($result) { echo'<form action="gIn2.php" method="post">'; echo"<table border='1'>"; echo"<tr><th>Student ID</th><th>Student First Name</th><th>Student Last Name</th><th>Student Grade</th>"; while($row = mysqli_fetch_array($result)) { //$student_id = $row['Student_id']; echo'<tr><td name="student_id">'.$row['Student_id'].'</td> <td>'.$row['S_first_name'].'</td> <td>'.$row['S_last_name'].'</td> <td><input type = "text" name="grade"/></td>';//name="grades['.$student_id.']" } echo"</tr>"; echo"</table>"; echo'<input type="submit" name="submit" value="Submit Grades">'; echo'</form>'; } else //error { echo"an error occured"; // do something } $row=mysqli_fetch_array($result); ?> i strone gradesIn.php Kod <?php
require_once('connect.php'); echo ' grades are in'; $gr= $_POST['grade']; //$sid = $_POST['Student_id']; $dbc = mysqli_connect (HOST, USERNAME, PASSWORD, DATABASE); //$sqlupdate2="UPDATE tblReportLog SET `Value` = '0' WHERE ReportID='$id'"; $qInsert="INSERT INTO grades (g_student_id, grade) VALUES ('g_student_id', '".$_POST['grade']."') where g_student_id = 'P018' AND g_module_code = 'AUD01';"; $result = mysqli_query($dbc,$qInsert); $q = "select g_student_id from grades where G_module_code = 'AUD01';"; $res = mysqli_query($dbc,$q); //echo $gr; echo '12'; if($result) { echo'result ok'; while($row = mysqli_fetch_array($result)) { echo'<td>'.$row['g_student_id'].'</td>'; echo'<td>'.$row[$_POST['grade']].'</td>'; //<td><input type = "text" name="'.$gr.'"/></td>';//name="grades['.$student_id.']" } } Ten post edytował kociaku 22.04.2012, 01:59:29 |
|
|
![]()
Post
#2
|
|
Grupa: Zarejestrowani Postów: 340 Pomógł: 49 Dołączył: 3.07.2009 Skąd: Rzeszów Ostrzeżenie: (0%) ![]() ![]() |
Na początek
$result = mysqli_query($dbc, $query); Według manuala pierwszym argumentem jest pytanie sql, a drugim identyfikator połączenia i tutaj $qInsert="INSERT INTO grades (g_student_id, grade) VALUES ('g_student_id', '".$_POST['grade']."') where g_student_id = 'P018' AND g_module_code = 'AUD01';"; To jest błędne zapytanie jeszcze to Cytat echo'<form action="gIn2.php" method="post">'; i strone gradesIn.php Skoro plik nazywa się gradesIn.php to musi być <form action="gradesIn.php" method="post">' Ten post edytował bpskiba 22.04.2012, 12:16:56 |
|
|
![]() ![]() |
![]() |
Wersja Lo-Fi | Aktualny czas: 16.06.2025 - 19:12 |