Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6682343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:41:41+00:00 2026-05-26T04:41:41+00:00

–EDITED TO BETTER DESCRIBE THE SCENARIO– I have a MySQL database containing 2 tables,

  • 0

–EDITED TO BETTER DESCRIBE THE SCENARIO–

I have a MySQL database containing 2 tables, technicians and work_orders. The technicians table has columns techID, tech_surname, tech_firstname and tech_userlogin. The work_orders table has columnsjobID (PK), wtechID, wtech_surname, wtech_firstname and wtech_userlogin among other things.

I have a page with a repeat region listing submitted work orders, the date of the work order is a link that passes the jobID in a URL to a page containing an update form. The form is populated with data taken from the work_orders table particular the the jobID (customer name, address, equip to repair, problem, etc.). On the form is a dropdown populated from the technicians table. This dropdown lists the tech_userlogin of the technicians. I have included hidden fields to the form page, wtech_userlogin and wtechID.
When I view the source of the page it shows the values from the work_orders table, but I don’t know how to work it into the query to accomplish the desired results.

When the form posts it updates the work_orders table. All of this is working.
What I am hoping to accomplish is to have the wtech_userlogin (from the work_orders table) for the particular work order become the default value of the dropdown menu if a technician has already been selected. If no selection has previously been made from the dropdown menu I would like the default of the dropdown to be “–Select Technician–“. I’ve tried a few things but nothing works so far.

Here is the code for the dropdown:

<select name="tech_userlogin" id="tech_userlogin">
              <?php
        $sql="SELECT techID, tech_userlogin FROM technicians";
$result=mysql_query($sql);

$options="";

while ($row=mysql_fetch_array($result)) {

    $techID=$row["techID"];
    $tech_userlogin=$row["tech_userlogin"];
    $options.="<option value=\"$tech_userlogin\">$tech_userlogin</option>";
}

if(empty($tech_userlogin)) {
die ('You must select a Technician');
}

?>
              <option value='<?php echo $options; ?>' selected='selected'>""<?php echo $options; ?>
          </select>

Can anyone help me with this problem? Any assistance will be appreciated. I’m very new at PHP and MySQL. I’m taking a course in web design and we use Dreamweaver. I want to break away from Dreamweaver and learn how to do this without the wizards. I’ve been able to get my forms to post and all of my insert, update and delete functions work from things I’ve been able to cobble together from the internet, but this one really has me stumped.

Cheers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:41:42+00:00Added an answer on May 26, 2026 at 4:41 am

    Something like this is what you want:

    <select name="tech_userlogin" id="tech_userlogin">
    <?php
        $sql="SELECT techID, tech_userlogin FROM technicians";
        $result=mysql_query($sql);
    
        while ($row=mysql_fetch_array($result)) 
        {
            $techID = $row['techID'];
            $tech_userlogin=$row['tech_userlogin'];
    
            // Here - check if the tech id in the query matches the logged in tech's id
            $selected = ($techID == $_SESSION['techID']) ? 'selected="selected"' : '';
    
            echo '<option value="' . $tech_userlogin . '" ' . $selected . '>' . $tech_userlogin . '</option>' . "\n";
        }
    
    ?>
    </select>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP application that stores PHP datetime to my MySQL table. I
So to start, I have an array of XML files. These files need to
Have a webpage that will be viewed by mainly IE users, so CSS3 is
I have a simple restful service that transforms a JAXB-anntotated beans to response XML
i have this code: <?php $valid_ext = array(pdf, doc); $args = array( 'post_type' =>
i have a text file with the following data: Calculated Concentrations 30.55 73.48 298.25
My NSXMLParser breaks on this string: <title>AAA &#8211; BCDEFGQWERTYUIO</title> I parsed it in this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
We have different types of hyphens/dashes (in some text) populated in db. Before comparing
The problem with unsigned char. I am reading a PPM image file which has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.