Jump to content

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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