Dropdown - with info populating into <input type="text"

Hi, doing my nut in here… I have a drop down… that works fine… but I would like 2 fields below the drop down in the form to populate other columns from the database it is getting the info from … not sure what I am doing wrong… can anyone help?

	<div class="form-group">
		<label>Site Reference:</label>
		<select class="form-control" name="SiteRef1" id="SiteRef1">
                <?php
                        // connect to the database
                        include('connect-db.php');
                        // get the records from the database
                        if ($result1 = $mysqli->query("SELECT * FROM developments ORDER BY siteref DESC"))
                        {
                                // display records if there are records to display
                                if ($result1->num_rows > 0)
                                {
                                        while ($row = $result1->fetch_object())
                                        {
                                                // set up a row for each record
                                                echo "<option>" . $row->siteref . "</option>";
												
                                        } 
                                }
                                // if there are no records in the database, display an alert message
                                else
                                {
                                        echo "No results to display!";
                                }
                        }
                        // close database connection
                        $mysqli->close();
                ?>
</select>
	</div>
	<div class="form-group">
		<label>Site Description:</label>
                <?php
                        // connect to the database
                        include('connect-db.php');
						
						
                        // get the records from the database
						if ($result = $mysqli->query("SELECT * FROM developments WHERE siteref = '$result1'"))
                        {
                                // display records if there are records to display
                                if ($result->num_rows > 0)
                                {
                                        while ($row = $result->fetch_object())
                                        {
                                                // set up a row for each record
                                                echo "<input type='text' class='form-control' name='sitedesc' value='" . $row->sitedesc . "'disabled>";
												
                                        } 
                                }
                                // if there are no records in the database, display an alert message
                                else
                                {
                                        echo "No results to display!";
                                }
                        }
                        // show an error if there is an issue with the database query
                        else
                        {
                                echo "Error: " . $mysqli->error;
                        }
                        // close database connection
                        $mysqli->close();
                ?>
	</div>

Benny,

What you're doing seems pretty straight forward, what's happening? Is the query you are using returning rows? Where is the code breaking down at?
Sponsor our Newsletter | Privacy Policy | Terms of Service