Note that there are some explanatory texts on larger screens.

plurals
  1. PONeed help in adding rollno and studentname into attendance table
    primarykey
    data
    text
    <pre><code>&lt;form name="reg" id="reg" method="post" action="&lt;?php echo $editFormAction; ?&gt;"&gt; &lt;table width="100%" border="0" align="center" cellpadding="4" cellspacing="4" style="text-align:left;"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;th width="117" height="39" bgcolor="#FFE1CC"&gt;Student RollNo&lt;/th&gt; &lt;th bgcolor="#FFE1CC"&gt;Student Name&lt;/th&gt; &lt;th width="100" bgcolor="#ECFAFF"&gt;Old Status&lt;/th&gt; &lt;th width="1" bgcolor="#FFE1CC"&gt;Present&lt;/th&gt; &lt;th width="1" bgcolor="#FFE1CC"&gt;Absent&lt;/th&gt; &lt;th width="1" bgcolor="#FFE1CC"&gt;Leave&lt;/th&gt; &lt;th width="1" bgcolor="#FFE1CC"&gt;Holiday&lt;/th&gt; &lt;/tr&gt; &lt;?php while ($students = mysql_fetch_array($result)) { ?&gt; &lt;tr&gt; &lt;td bgcolor="#EAFAFF" class="table1"&gt;&lt;?php $id = $students['memberid']; ?&gt;&lt;?php echo $_POST['department']; ?&gt;-&lt;?php echo $students['rollno']; ?&gt;&lt;/td&gt; &lt;td bgcolor="#EAFAFF" class="table1"&gt;&lt;?php echo $students['fullname']; ?&gt;&lt;/td&gt; &lt;td align="center" bgcolor="#ECFAFF" class="table1"&gt;&lt;?php echo $students['current']; ?&gt;&lt;/td&gt; &lt;td width="1" align="center" bgcolor="#FFE2D5" id="present"&gt;&lt;input type="radio" name="present[&lt;?php echo $students['memberid']; ?&gt;]" value="Present" /&gt;&lt;/td&gt; &lt;td width="1" align="center" bgcolor="#FFE2D5" id="absent"&gt;&lt;input type="radio" name="present[&lt;?php echo $students['memberid']; ?&gt;]" value="Absent" /&gt;&lt;/td&gt; &lt;td width="1" align="center" bgcolor="#FFE2D5" id="leave"&gt;&lt;input type="radio" name="present[&lt;?php echo $students['memberid']; ?&gt;]" value="Leave" /&gt;&lt;/td&gt; &lt;td width="1" align="center" bgcolor="#FFE2D5" id="holiday"&gt;&lt;input type="radio" name="present[&lt;?php echo $students['memberid']; ?&gt;]" value="Holiday" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;input name="fullname" type="hidden" value="&lt;?php echo $students['fullname']; ?&gt;"&gt; &lt;input name="rollno" type="hidden" value="&lt;?php echo $students['rollno']; ?&gt;"&gt; &lt;input name="percent" type="hidden" value="&lt;?php echo $students['percent']; ?&gt;"&gt; &lt;input name="department" type="hidden" value="&lt;?php echo $_REQUEST['department']; ?&gt;"&gt; &lt;input name="semester" type="hidden" value="&lt;?php echo $_REQUEST['semester']; ?&gt;"&gt; &lt;input name="session" type="hidden" value="&lt;?php echo $_REQUEST['sessionfrom']; ?&gt;-&lt;?php echo $_REQUEST['sessionto']; ?&gt;"&gt; &lt;input name="subject" type="hidden" value="&lt;?php echo $_REQUEST['subject']; ?&gt;"&gt; &lt;input name="date" type="hidden" value="&lt;?php echo date("m-d-Y"); ?&gt;"&gt; &lt;?php } ?&gt; &lt;tr&gt; &lt;td colspan="6" style="vertical-align:middle; text-align: center;"&gt;&lt;br /&gt; &lt;input id="Submit" type="submit" name="Submit" value="Submit" style="text-align: center; background-color: #000000; color: #ffffff; border: 1px #000000 solid;" /&gt;&lt;/td&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;input type="hidden" name="MM_insert" value="reg" /&gt; &lt;/form&gt; &lt;?php if (($_POST["MM_insert"] == "reg")){ foreach($_POST['present'] as $student_id =&gt; $value) { $sql = "UPDATE members SET current = '".$value."' WHERE memberid = '".$student_id."' "; $result = mysql_query($sql); $sql1 = "INSERT INTO student_attendance (department, semester, session, subject, current, percent, date) VALUES ('".$_REQUEST['department']."','".$_REQUEST['semester']."','".$_REQUEST['session']."','".$_REQUEST['subject']."','$value','".$_REQUEST['percent']."','".$_REQUEST['date']."')"; $result = mysql_query($sql1); } header("Location: attendance.php"); } ?&gt; </code></pre> <p>Hello Above is my code, everything seem to be working fine. List of students with name, rollno appears as well from members table, and when submit, the status of students of present to either absent or present working fine, it goes well into attendance_record individual, example submitted record of 20 students, 20 rows added with different present status however student name and rollno is coming to be Null.... I have removed the rollno and studentname currently because of only first student name is repeating 20 time and rollno as well.</p> <pre><code> &lt;?php if (($_POST["MM_insert"] == "reg")){ foreach($_POST['present'] as $student_id =&gt; $value) { $sql = "UPDATE members SET current = '".$value."' WHERE memberid = '".$student_id."' "; $result = mysql_query($sql); $sql1 = "INSERT INTO student_attendance (department, semester, session, subject, current, percent, date) VALUES ('".$_REQUEST['department']."','".$_REQUEST['semester']."','".$_REQUEST['session']."','".$_REQUEST['subject']."','$value','".$_REQUEST['percent']."','".$_REQUEST['date']."')"; $result = mysql_query($sql1); } header("Location: attendance.php"); } ?&gt; </code></pre> <p>Kindly help me correcting it, i cannot use foreach function with more values can you tell how to use while or for for below code, so all student names, rolls including status get submit to attendance_view table ?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload