fate14300 01:16:15 | good day, i will ask.. the code is in pdo.. it is very hard for me to do a insert into table and update through that format.. anyone help me..!! Thanks in advance . btw here is my form code. <?Php $dbhost_name = "localhost"; $database = "employee"; $username = "root"; try { $dbo = new PDO('mysql:host='.$dbhost_name.';dbname='.$database, $username, $password); } catch (PDOException $e) { print "Error!: " . $e->getMessage() . "<br/>"; die(); } ?> <SCRIPT language=JavaScript> function reload(form) { var val=form.cat.options[form.cat.options.selectedIndex].value; self.location='dd.php?cat=' + val ; } </script> <?Php @$cat=$_GET['cat']; $quer2="SELECT DISTINCT emp_number FROM personnel_info order by emp_number"; $quer="SELECT last_name,first_name,middle_name FROM personnel_info where emp_number={$cat} order by emp_number"; echo "<form method='post' action='dd1.php'>"; echo "<p><strong><font size='+2'>Leave Application Form</font></strong></p>"; echo "<br>"; echo "Employee Number:   "; echo "<select name='cat' onchange=\"reload(this.form)\"><option value=''>-- select --</option>"; foreach ($dbo->query($quer2) as $noticia2) { if($noticia2['emp_number']==@$cat){echo "<option selected value='$noticia2[emp_number]'>$noticia2[emp_number]</option>"."<BR>";} else{echo "<option value='$noticia2[emp_number]'>$noticia2[emp_number]</option>";} } echo $noticia2 ; echo "</select>"; echo "<br><br>"; echo "                                   Last Name    First Name  Middle Name"; echo "<br>"; echo "                                 "; foreach ($dbo->query($quer) as $noticia) { echo "  <input type=text name=Fname value='$noticia[last_name]' disabled=disabled size=5>     "; echo "<input type=text name= Lname value='$noticia[first_name]' disabled=disabled size=5>     "; echo "<input type=text name=Mname value='$noticia[middle_name]' disabled=disabled size=5>"; } echo "</select>"; echo "<br><br>"; echo "Date Filed:           "; echo "<input type='date' name='Dfiled'>"; echo "<br><br>"; echo "PERIOD COVERED:"; echo "<br>"; echo "     From Date:     "; echo "<input type='date' name='Fdate'>"; echo "<br>"; echo "     To Date:         "; echo "<input type='date' name='Tdate'>"; echo "<br>"; echo "     No. of Day/s: "; echo "<input type='text' name='Day' size='1'>"; echo "<br><br>"; echo "Option:;"; echo "<br>"; echo "     <input type='radio' name='Option'> Sick"; echo "<br>"; echo "     <input type='radio' name='Option'> Vacation"; echo "<br>"; echo "     <input type='radio' name='Option'> Maternity"; echo "<br>"; echo "     <input type='radio' name='Option'> Paternity"; echo "<br><br>"; echo "Other:    "; echo "<input type='text' name='Other'>"; echo "<br><br>"; echo "Reason: "; echo "<input type='text' name='Reason'>"; echo "<br><br>"; echo "                             <input type=submit name=submit value=submit>"; echo "</form>"; ?> |
smo1234 01-14-2015 | It is very difficult to find problem this way. Please post the error message or output you are getting from this. You can read this to know the solution of drop down list box |
fate14300 01-16-2015 | there is no error sir, but when i click the submit button it didnt insert into table.. ! here is my submit form code.. <?php if (isset($_POST['submit'])) { include ('connect.php'); $enumber=$_POST['cat'] ; $lname= $_POST['Lname'] ; $fname=$_POST['Fname'] ; $mname=$_POST['Mname'] ; $dfiled=$_POST['Dfiled'] ; $fdate=$_POST['Fdate'] ; $tdate=$_POST['Tdate'] ; $day=$_POST['Day'] ; $option=$_POST['Option'] ; $other=$_POST['Other'] ; $reason=$_POST['Reason'] ; echo $enumber ; mysql_query("INSERT INTO `leave_application` (employee_number,last_name,first_name,middle_name,date_filed,from_date,to_date,day,option,other,reason) VALUES ('$enumber','$lname','$fname','$mname','$dfiled','$fdate','$tdate','$day','$option','$other','$reason')"); } ?> <br><br><br><center>1 record added! <style type="text/css"> body { font-family:verdana,arial,sans-serif; font-size:10pt; margin:50px; background-color:#d0e4fe; } </style> |
smo1234 01-16-2015 | I am not seeing any database connection in your script. It should open before you execute any query. It is better to use PDO than old style database connection string. Read more on how to connect and manage database using PDO here |
fate14300 01-16-2015 | sorry im new in programming .. idk how to use pdo .. xD i just use mysql in connecting database -.- help me pls . thnx in advance .! |
smo1234 01-17-2015 | In the link given above there are sample codes and it is explained in PDO section. You must have PHP already running. |
fate14300 01-17-2015 | its ok now sir. btw thanks. just a simple error! :) |