php - Dropdown values are not inserting in mysql -
in code dropdown values not inserting mysql database.the exam_name inserting course_code col.and course_code value not inserting in mysql.so please me.the exam_name populate examcourse when selected course_code corresponding exam_name wil display exam_course.
upload2_view.php
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $(".hai").change(function() { var id=$(this).val(); // please find course_code, course_code not found var datastring = 'course_code='+ id; $.ajax ({ type: "post", url: "upload_view2.php", data: datastring, cache: false, success: function(html) { $(".hai2").html(html); } }); }); }); </script> </head> <form enctype="multipart/form-data" action="<?php echo $_server['php_self']; ?>" method="post"> file import:<br /> <input size='30' type='file' name='filename'> select exam name:<select name=hai class="hai"> <?php mysql_connect("localhost", "root", "") or die("error connecting database: ".mysql_error()); mysql_select_db("slseatapp") or die(mysql_error()); $query="select distinct exam_name examcourse"; $result = mysql_query($query); while($nt=mysql_fetch_array($result)) { echo "<option value='".$nt['exam_name']."'>".$nt['exam_name']."</option>"; } ?> </select> <input type="submit" name="submit" value="upload"></form> <?php mysql_connect("localhost", "root", "") or die("error connecting database: ".mysql_error()); mysql_select_db("slseatapp") or die(mysql_error()); //upload file if (isset($_post['submit'])) { if (is_uploaded_file($_files['filename']['tmp_name'])) { //import uploaded file database $row = 1; $handle = fopen($_files['filename']['tmp_name'], "r"); $var = $_post['hai']; $var1 = $_post['hai2']; while (($data = fgetcsv($handle, 1000, ",")) !== false) { //update database values $import="insert student_table (id,register_number,name,course_code,subject_code,exam_name) values('".mysql_real_escape_string($data[0])."', '".mysql_real_escape_string($data[1])."','".mysql_real_escape_string($data[2])."','$var','$var1','$var2')"; $import="replace student_table (id,register_number,name,course_code,subject_code,exam_name) values('".mysql_real_escape_string($data[0])."', '".mysql_real_escape_string($data[1])."','".mysql_real_escape_string($data[2])."','$var','$var1','$var2')"; mysql_query($import) or die(mysql_error()); } } fclose($handle); echo"<script>alert('uploaded successfully');</script>"; } ?> <br />
upload_view2.php
<?php mysql_connect("localhost", "root", "") or die("error connecting database: ".mysql_error()); mysql_select_db("slseatapp") or die(mysql_error()); ?> <form enctype="multipart/form-data" action="<?php echo $_server['php_self']; ? >" method="post"> <?php @$exam_name=$_post['course_code']; ?> course code:<select name="hai2"> <?php $query="select distinct course_code examcourse exam_name = '$exam_name' "; $result = mysql_query($query); while($nt=mysql_fetch_array($result)) { echo "<option value='".$nt['course_code']."'>".$nt['course_code']."</option>"; } ?> </select> <br />
Comments
Post a Comment