Jump to content

Jonas70

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Jonas70's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. My problem is now solved. Thank you very much for your help guys. You are wonderful people. Thank you now I will have a nice weekend. My form and getting value of radio buttons was totaly wrong. God bless you!
  2. Thank you sir! I tried like this: <?php if (isset($_REQUEST['submit']) && $_REQUEST['submit'] != "") { if(isset($_POST['attendance'])) // Even tried if(isset($_POST['attendance['.$row['student_id'].']'])) I don't know which one is correct { // I tried this one $absens_id = $_POST['attendance']; // and by this one $absens_id = $_POST['attendance['.$row['student_id'].']']; //attendance['.$row['staff_id'].'] for ($i=0; $i<sizeof($absens_id);$i++) { $sql2 = " INSERT INTO absence (absens_id ) ". " VALUES ('".$absens_id[$i]."') "; mysql_query($sql2) or die(mysql_error()); } } } ?> But I think the most problem is the hole form. Right now it's as following: <?php while($row = mysql_fetch_array($result)) { print '<tr>'. '<td>'.$row['firstname'].'</td>'. '<td>'. $row['lastname'] . '</td>'. '<td>'. '<form name="abs" method="POST" action="getuser.php" enctype="multipart/form-data">'. //'<form action="getStudents.php" method="POST" >'. '<input type="radio" name="attendance['.$row['student_id'].']" value="1">Accepted</input>'. '<input type="radio" name="attendance['.$row['student_id'].']" value="2">Not accepted</input>'. '<input type="radio" name="attendance['.$row['student_id'].']" value="3">Tardy</input>'. // If I put submit here then it gavs me submit button to every student. But I want one submit for all '<input type="submit" name="submit" value="Send">'. '</td>'. '</tr>'; } // If I put submit button here with the same name then it didn't reacting no responding '<form name="abs" method="POST" action="getuser.php" enctype="multipart/form-data">'. print '<input type="submit" name="submit" value="Send">'. '</form>'. '<tr>'. '<td>'. '</td>'. print '</table>'; ?> I realy don't know how to correct it.
  3. Mahngiel: First of all, thank you for your response. I don't have deeply experience in development but I'am not either a very new beginner. I know litle about arrays, and chexboxes are not problem. I did a file upload function with multiple chekboxes that I could chose many classes(stil talking about student classes like Class 6A, 7A...) , and that function give every marked (chosen) class permision to see and oppen the file. I hope you understand what I mean. But When I want to wark with radio buttons .. I coudn't make it... they are make me out of my mind. To chose class and populate the students name generate from database to a table it wasn't difficult , but radio buttons.. the must have different name (every group must have different name.. as I understand) Maybe by doing FOR sats pr FOREACH sats.. so I realy apricate your help. Thank you again.
  4. First of all I want to thank you in advance for your spending time to help me. I am making attendance form to my school with multiple radio buttons. Students and their classes are in a database and when a teacher chose class , let say class 7 then all students name of class 7 populate as a list in a table. And beside every student's name there will be three radio buttons to chose. Those's value will be Accepted , Not accepted , and Tardy. To poplate students I use Java function as below:(found in W3school) the first page. Let say populate.php <html> <head> <script type="text/javascript"> function showUser(str) { if (str=="") { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","getuser.php?q="+str,true); xmlhttp.send(); } </script> </head> <body> <form> <select name="users" onchange="showUser(this.value)"> <option value="">Select a class:</option> <?php getClasses(); ?> </select> </form> <br /> </body> </html> // And the second page will be offcourse users.php and is as below: <?php $q=$_GET["q"]; $sql = "SELECT s.firstname, s.lastname, s.student_id, s.class_id, cl.class_id ". " FROM students s ". " INNER JOIN classes cl ON cl.class_id = s.class_id ". " WHERE s.class_id =$q "; $result = mysql_query($sql); print '<table border="2">'. '<tr>'. '<th>Firstname</th>'. '<th>Lastname</th>'. '<th>Kind of absence</th>'. '</tr>'; while($row = mysql_fetch_array($result)) { print '<tr>'. '<td>'.$row['firstname'].'</td>'. '<td>'. $row['lastname'] . '</td>'. '<td>'. '<form method="post" action="getuser.php">'. '<input type="radio" name="attendance[]" value="1">Accepted</input>'. '<input type="radio" name="attendance[]" value="2"> Not accepted</input>'. '<input type="radio" name="attendance[]" value="3"> Tardy</input>'. '</form>'. '</td>'. '</tr>'; } print '<tr>'. '<td>'. '<form method="post" action="getuser.php">'. '<input type="submit" name="submit" value="Send"> &nbsp'. '</form>'. '</td>'. <?php // I don't know where to put the submit button form. print '</table>'; //What I'am trying is to get all values of radio buttons and insert them in database. [code] <?php if (isset($_REQUEST['submit']) && $_REQUEST['submit'] != "") { if(isset($_POST['attendance'])) { $atendance = $_POST['attendance']; for ($i=0; $i<sizeof($attendance);$i++) { ?> // I don't how but I know I have to collect student_id's too in array maybe here [code] <?php $sql2 = " INSERT INTO absence (student_id, attendans_id ) ". " VALUES (".$student_id.", '".$attendance[$i]."') "; mysql_query($sql2) or die(mysql_error()); } } } ?> //So dear PHP lovers... I know I doing totaly wrong but I don't know how to fix this problem and I would be greatful if you can help me. Thank you again in advance. There will be three radio buttons for teachers to chose för every student. I mean Beside every student name there will be three alternativ to chose.... three radio buttons for every student with value accepted, not accepted and Tardy. Then collect all those value of buttons and student's id's and insert them in database. I think I can collect student id's by doing this way: <?php while ($row_st = mysql_fetch_assoc($students)){ $studentarray[] = $row_st['student_id']; } foreach($studentarray as $value) { $sql_stu = "INSERT INTO attendanse (student_id, absense_id) VALUES ('$value', '$absens_id')"; mysql_query($sql_stu) OR die(mysql_error()); // The problem is How can I get value of buttons, value of absence_id. Please Help! // Don't forget to see attached image b/c // one picture says 1000 words. } ?>
  5. First of all I want to thank you in advance for your spending time to help me. I am making attendance form to my school with multiple radio buttons. Students and their classes are in a database and when a teacher chose class , let say class 7 then all students name of class 7 populate as a list in a table. And beside every student's name there will be three radio buttons to chose. Those's value will be Accepted , Not accepted , and Tardy. To poplate students I use Java function as below:(found in W3school) the first page. Let say populate.php <html> <head> <script type="text/javascript"> function showUser(str) { if (str=="") { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","getuser.php?q="+str,true); xmlhttp.send(); } </script> </head> <body> <form> <select name="users" onchange="showUser(this.value)"> <option value="">Select a class:</option> <?php getClasses(); ?> </select> </form> <br /> </body> </html> <?php // And the second page will be offcourse users.php and is as below: $q=$_GET["q"]; $sql = "SELECT s.firstname, s.lastname, s.student_id, s.class_id, cl.class_id ". " FROM students s ". " INNER JOIN classes cl ON cl.class_id = s.class_id ". " WHERE s.class_id =$q "; $result = mysql_query($sql); print '<table border="2">'. '<tr>'. '<th>Firstname</th>'. '<th>Lastname</th>'. '<th>Kind of absence</th>'. '</tr>'; while($row = mysql_fetch_array($result)) { print '<tr>'. '<td>'.$row['firstname'].'</td>'. '<td>'. $row['lastname'] . '</td>'. '<td>'. '<form method="post" action="getuser.php">'. '<input type="radio" name="attendance[]" value="1">Accepted</input>'. '<input type="radio" name="attendance[]" value="2"> Not accepted</input>'. '<input type="radio" name="attendance[]" value="3"> Tardy</input>'. '</form>'. '</td>'. '</tr>'; } print '<tr>'. '<td>'. '<form method="post" action="getuser.php">'. '<input type="submit" name="submit" value="Send"> &nbsp'. '</form>'. '</td>'. // I don't know where to put the submit button form. print '</table>'; //What I'am trying is to get all values of radio buttons and insert them in database. if (isset($_REQUEST['submit']) && $_REQUEST['submit'] != "") { if(isset($_POST['attendance'])) { $atendance = $_POST['attendance']; for ($i=0; $i<sizeof($attendance);$i++) { // I don't how but I know I have to collect student_id's too in array maybe here $sql2 = " INSERT INTO absence (student_id, attendans_id ) ". " VALUES (".$student_id.", '".$attendance[$i]."') "; mysql_query($sql2) or die(mysql_error()); } } } //So dear PHP lovers... I know I doing totaly wrong but I don't know how to fix this problem and I would be greatful if you can help me. Thank you again in advance. There will be three radio buttons for teachers to chose för every student. I mean Beside every student name there will be three alternativ to chose.... three radio buttons for every student with value accepted, not accepted and Tardy. Then collect all those value of buttons and student's id's and insert them in database. I think I can collect student id's by doing this way: while ($row_st = mysql_fetch_assoc($students)){ $studentarray[] = $row_st['student_id']; } //echo count($studentarray); foreach($studentarray as $value) { //echo $value. "<br>"; $sql_stu = "INSERT INTO attendanse (student_id, absense_id) VALUES ('$value', '$absens_id')"; mysql_query($sql_stu) OR die(mysql_error()); // The problem is How can I get value of buttons, value of absence_id. Please Help! // Don't forget to see attached image b/c one picture says 1000 words. }
×
×
  • 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.