Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

SimpleXML

Avatar of bobby101
bobby101 asked on
Web Languages and StandardsPHPXML
2 Comments1 Solution522 ViewsLast Modified:
hi
Im tryin t get values and pass it into a form for edit, but the value dont pick up.

My xml is
<?xml version="1.0"?>
<quizzes>
      <quiz>
            <unit>1111</unit>
            <lecture>1</lecture>
            <question number="1">
                        <name>What color is the sky?</name>
                        <correct>Blue</correct>
                        <answers>
                              <answer order="1">Green</answer>
                              <answer order="2">Yellow</answer>
                              <answer order="3">Blue</answer>
                              <answer order="4">Purple</answer>
                        </answers>
            </question>
      </quiz>
</quizzes>

and my code
// SEARCH
if (array_key_exists('search', $_POST))
{  
      $file = "files/quiz.xml";
      $obj = simplexml_load_file($file);
      $cc = $_POST['code'];
      $target = $_POST['target'];
      $num = $_POST['aNum'];
      
      if($target !="" && $cc !="")
      {
      //echo $num;
            foreach ($obj->quiz->unit as $unit){
                  if ($cc == (string) $unit){
                  //echo (string) $unit;
                        foreach ($unit->lecture as $lecture)
                        {
                              if ($target == (string) $lecture)
                              {
                                    foreach($lecture->question as $question)
                                    {                                    
                                          if($num == (string) $question['number']){
                                          $questionName = (string) $question->name;                                          
                                          }
                                          
                                    }
                              }//end if target
                        }
                  }//end if $course == $cc                   
            }//unit foreach
      }else {$error = 'Not Found, Please Enter the Valid Enteries';}
}

THE VALUE DOESN"T EVEN ECHO

ASKER CERTIFIED SOLUTION
Avatar of hernst42
Commented:
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answers