Jump to content

DropDown List link with textboxes


umairahmedkhan

Recommended Posts

Hello,

 

i have a simple database containing three tables

 

subject_code

subject_name

subject_description

 

i have a dropdown list in which i fetch data of 'subject code'

 

now i want to show the other field data in the textboxes of the selected row item from the drop down list

 

can anybudy help me out in code

 

_________________________________ Code __________________________________________

 

 

<?php 
 
$connect_error = 'Sorry we are experiencing some connection problems.';
mysql_connect('localhost', 'root', '') or die ($connect_error);
mysql_select_db('lr_u') or die ($connect_error);
 
function close(){
   mysql_close();
}
 
function query() {
$sql = mysql_query("SELECT * FROM ref_subject");     
while($rows = mysql_fetch_array($sql)) {
   echo '<option value="' . $rows['subject_code'] . '">' . $rows['subject_code'] . '" </option>';      
}
}
 
?>
 
<h1> Creating an Examination Paper </h1>
<p> Welcome to the section where you can create an online examination paper </p>
 
    <h3> Subject </h3>
 
<form action="" method="post">
<ul>
<li> Subject Code*:<br>
   <select name="dropdown">
              <?php  query()     ?>
   </select>
        <?php   close()   ?>
<br>
Select The Subject Code Of the Course.
<br>
</li>
<li> Subject Name*:<br> 
<input type="text" name="subject_name">
</li>
<li> Subject Discription*:<br>
<TEXTAREA ROWS=10 COLS=50 type="text" name="subject_description" ></TEXTAREA>
</li>
<br>
<p>  kindly sumbit to check if the coudse is valid </p>
<input type="submit" value="Submit">
</li>
</ul>
</form>
 
 

exam_create.php

Link to comment
https://forums.phpfreaks.com/topic/275263-dropdown-list-link-with-textboxes/
Share on other sites

Welcome to phpfreaks.

 

I need to mention something about your coding.

 

Please, don't use mysql_* functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements  instead, and use PDO  or MySQLi  - this article will help you decide which. If you choose PDO, here is a good tutorial.

 

Now tell us whats your problems with your coding. Is there any errors?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.