Dinzy Posted April 6, 2011 Share Posted April 6, 2011 Hello all, I have three text fields ( hosteladmissionnumber,branch & Semester) and three text boxes in a form. When i provide the hostel admission number , the corresponding branch semester must be acquired from the registrationtable in DB and fill it in text boxes. How can i do it? any help would be appreciated. Thanks. I have pasted the code below. [syntax=php] <?php session_start(); $hostad=$_POST['hosteladmissionno']; $sem=$_POST['student_name']; $sem=$_POST['semester']; $con=mysql_connect('localhost','root',''); if(!$con) { die('Unable to connect'.mysql_error()); } mysql_select_db('hostel',$con); //i have to insert the hosteladmission in payment too..but no need to insert semester and branch $r1="INSERT INTO payment(hosteladmissionno) values ('$hostad')"; mysql_close($con); ?> /HTML PART <form action='payment.php' method='POST' name='form1'> <center> <table> <tr><td><b>Admission No:</b></td><td><input type='text' name='hosteladmissionno'></td></tr> <tr><td><b>Student Name:</b></td><td><input type='text' name='student_name'></td></tr> <tr><td><b>Semester:</b></td><td><input type='text' name='semester'></td></tr> [/syntax] Quote Link to comment https://forums.phpfreaks.com/topic/232834-auto-filling-the-text-boxes-from-database/ Share on other sites More sharing options...
monkeytooth Posted April 6, 2011 Share Posted April 6, 2011 Well your existing code shown no offence makes no sense, as on page load its going to get an SQL error, as there is no connection to work with. However if its defined somewhere else and you havent shown that, ok.. but with this code from the looks of it your just posting empty data to a database as soon as the page loads.. If you want to auto populate fields in the form then you need to query an existing database for what you want those field values to be.. then in the <input> tags you put a line value="$myDBValue" (of course you need to edit it to your needs.. but generally speaking thats all there is to auto population the code given here really doesnt make sense to your described need and desire though, and youve provided little background otherwise on how your orgainizing your data for use to do auto populations and otherwise so its not likely anyone can really help you much unless more is known. Quote Link to comment https://forums.phpfreaks.com/topic/232834-auto-filling-the-text-boxes-from-database/#findComment-1197667 Share on other sites More sharing options...
Dinzy Posted April 7, 2011 Author Share Posted April 7, 2011 Thanks for the Reply. What are the details you wanna know? I wil try to Update my Question. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/232834-auto-filling-the-text-boxes-from-database/#findComment-1198076 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.