Jump to content

nithan

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

nithan's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. ----------------------------------------- Thank you. This is the code that I am using: I am very new to PHP. Please correct me if I am wrong. This is my Form code: <style type="text/css"> table.hovertable { font-family: verdana,arial,sans-serif; font-size:11px; color:#333333; border-width: 1px; border-color: #999999; border-collapse: collapse; } table.hovertable th { background-color:#c3dde0; border-width: 1px; padding: 8px; border-style: solid; border-color: #a9c6c9; } table.hovertable tr { background-color:#d4e3e5; } table.hovertable td { border-width: 1px; padding: 8px; border-style: solid; border-color: #a9c6c9; } table.hovertable { width: 30%; text-align: center; font: 14px Verdana, Arial, Helvetica, sans-serif; } tr.yellow td { border-top: 1px solid #FB7A31; border-bottom: 1px solid #FB7A31; background: #FFC; font: 20px Verdana, Arial, Helvetica, sans-serif; } </style> <script> function confirmDelete(delUrl) { if (confirm("Are you sure you want to delete")) { document.location = delUrl; } } </script> <script type="text/javascript"> function enableText(checkBool, textID) { textFldObj = document.getElementById(textID); //Disable the text field textFldObj.disabled = !checkBool; //Clear value in the text field if (!checkBool) { textFldObj.value = ''; } } </script> <html> <body> <? include("attendrop.php"); ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <label class="form-label-left" id="label_4" for="input_4">Select Training: </label> <div id="cid_4" class="form-input"> <select class="form-dropdown" style="width:150px" id="input_4" name="training"> <OPTION VALUE=0>Choose <?=$optionsa?> </SELECT> <input type="submit" name="submit" value="Mark Attendance"><br> </form> <?php if(isset($_POST['submit'])) $training= $_POST['training']; { ?> <div align="center"> Mark Attendance for <font color="red"> <? echo $training; ?> </font>Training. <form method="post" action="attendinsert.php" > <input type="hidden" value="<? echo $training; ?>" name="training" /> <table class="hovertable" align="center" width="30%" cellpadding="50" > <tr class="yellow"> <tr> <td><font face="Arial, Helvetica, sans-serif">Name</font></td> <td><font face="Arial, Helvetica, sans-serif">OSS ID</font></td> <td><font face="Arial, Helvetica, sans-serif">Mark Attendance</font></td> <td><font face="Arial, Helvetica, sans-serif">Marks</font></td> <?php include("database.php"); $training= $_POST['training']; $from= $_POST['from']; $to= $_POST['to']; $tablename="agentstable"; $query="SELECT * FROM agentstable ORDER BY name ASC"; $result=mysql_query($query); $num=mysql_numrows($result); $options=""; $i=0; while ($i < $num) { $id=mysql_result($result,$i,"id"); $name=mysql_result($result,$i,"name"); $empcode=mysql_result($result,$i,"emp_code"); $oss=mysql_result($result,$i,"oss_username"); $emails=mysql_result($result,$i,"emailaddress"); ?> <tr onmouseover="this.style.backgroundColor='#ffff66';" onmouseout="this.style.backgroundColor='#d4e3e5';"> <td><? echo $name; ?></td><td><? echo $oss; ?></td><td> <input id="myCheckBox" type='checkbox' onclick="enableText(this.checked, '<? echo $name; ?>');" name='student[<? echo $name; ?>]' value='1' /> </td><td> <input id='<? echo $name; ?>' type='text' name='students[<? echo $name; ?>]' disabled="disabled"/></td> </tr> <?php $i++; } ?> </table> <input type='submit' value='Submit' name='submit_button' /> </form> </div> <? } ?> </div> </body> </html> This code is to insert: <?php include("database.php"); $tablename="agentstable"; date_default_timezone_set('Asia/Calcutta'); $format = 'm/d/Y'; $today = date ( $format ); if(!isset($_POST['submit_button'])){ //form has not been submitted return; } //form HAS been submitted $student_array = $_POST['student']; $trainings = $_POST['training']; $marks= $_POST['students']; $marksn = array_filter($marks); /*foreach($marks as $marks=>$vals){ } */ foreach($student_array as $name=>$val){ $val = ($val == "1")?1:0; if($val == 1) { //$val needs to be 0 or 1. foreach($marksn as $name=>$vals){ trim($vals) !== ''; $query="INSERT INTO attend (Name, Training, Date, Attendance, Marks) VALUES ('$name','$trainings','$today','$val','$vals')"; $result=mysql_query($query); } } if($result){ echo("<br>Input data is succeed"); echo "<a href='attendanceform.php'>Back to Attendance Page</a>"; } else { echo("<br>Input data is fail"); } } mysql_close(); ?>
  2. I have a form which displays name and a text field after fetching names from the database in an array: <input id='<? echo $name; ?>' type='text' name='students[<? echo $name; ?>]' disabled="disabled"/> Example: Name and TextField. When I want to insert it in database, I can't insert. Following is the code that I am using. Am I doing right thing? $marks= $_POST['students']; $marksn = array_filter($marks); foreach($marksn as $name=>$vals){ trim($vals) !== ''; $query="INSERT INTO attend (Name, Training, Date, Attendance, Marks) VALUES ('$name','$trainings','$today','$val','$vals')"; $result=mysql_query($query);
  3. Wow... Thanks a lot.. It worked for me...... You rock man..
  4. Hello, I have a code which displays name and number. It is working now but I want to sort the content on the basis of number... The code is given below: while($rows = mysql_fetch_array($results)){ echo "". $rows['username'] ." ". $rows['COUNT(Completed_Sales)'] .""; echo "<br />"; } The result will look like this Name Prdoducts.
×
×
  • 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.