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 7700997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:52:43+00:00 2026-05-31T22:52:43+00:00

I’m new to web development.I have a php file such as addcourse.php.In this file

  • 0

I’m new to web development.I have a php file such as addcourse.php.In this file there is a code block in a form like this:

<select name="instructor-id" id="instructor-id">
    <option >    </option>
</select>

With this code user must select an instructor to add course to it.Instructor names must shown to user.I want to add elements to option tag from a xml file.Xml file has many instructors.(instructors.xml) Instructors that user can see with option tag must be from this instructors.xml file.I tried to get instructors with foreach in php tag but then i realized that option tag doesn’t work in php tag.I looked for a loop which can work in html but i couldn’t get any answers.What is the true way to solve this problem?Thanks for help.

  • 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-31T22:52:44+00:00Added an answer on May 31, 2026 at 10:52 pm

    Here you can user DOMDocument() class to get the all node values and attributes values.

       <?php
        $xml = '<instructors> 
            <instructor instructorId="1">ozge yal</instructor> 
            <instructor instructorId="2">abd yal</instructor> 
            <instructor instructorId="3">anıl yal</instructor> 
            <instructor instructorId="4">gizem ort</instructor> 
            <instructor instructorId="5">bosluk</instructor> 
            <instructor instructorId="6">marry</instructor> 
            <instructor instructorId="7">john</instructor> 
            <instructor instructorId="8">jenny</instructor> 
            <instructor instructorId="9">tom</instructor> 
            <instructor instructorId="10">brad</instructor> 
        </instructors>';
    
        $dom = new DOMDocument();
        $dom->loadXML($xml);
    
        foreach ($dom->getElementsByTagName('instructors') as $taginstructors)
        {
            foreach ($taginstructors->getElementsByTagName('instructor') as $taginstructor)
            {
                $instructor_array[] = $taginstructor->nodeValue; 
                $instructorId_array[]=$taginstructor->getAttribute('instructorId');
            }
        }
    
        // Here $taganswer_array is an array, contained all the instructor options.
        ?>
    
        <!-- You can display like this. -->
        Select Instructor: 
        <select>
            <?php
                foreach($instructor_array as $key=> $val)
                {
                    $id=$instructorId_array[$key];
                    echo "<option value='$id'>".$val."</option>";
                }
            ?>
        </select>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I want use html5's new tag to play a wav file (currently only supported
I am trying to render a haml file in a javascript response like so:

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.