Reputation: 947
Example- Consider three textboxes. In the first one, im providing ID or number ( primary key in my table). Using the ID, the semester and branch should be auto filled using the ID. ( All the three fields are in same table- in my DB). HTML part:
<input type='text' name='hosteladmissionno'>
<input type='text' name='student_name'>
<input type='text' name='semester'>
PHP,Mysql part:
<?php
session_start();
$hostad=$_POST['hosteladmissionno'];
$sem=$_POST['student_name'];
$sem=$_POST['semester'];
$r1="INSERT INTO payment(hosteladmissionno)VALUES ('$hostad')";
Now i want the fields student_name and semester to be autofilled for the correspoinding hosteladmissionno. Can this be done by Ajax or Jquery? If so.. How can i implement in this Code? Note: hosteladmissionno,student_name and semester belongs to registration tablem in my database. I need to retrieve the values from that table.Thanks in advance.
Upvotes: 0
Views: 2023
Reputation: 6825
What do you mean auto-filled? The query that you've provided only the hosteladmissionno will be inserted. Unless you have a default value for the other column. But if you intended to insert the text you forward, you should also add it in your insert value. Something like this.
$r1 = "INSERT INTO payment(hosteladmissionno, student_name, semester)VALUES ('$hostad','$sem_student_name','$sem_semester')";
I don't know why you use the same variable in two different field. Does only the last initialization will be its value.
See some tutorials:
Post MySQL Result Using AJAX via jQuery
Upvotes: 1