Page 339 - Open Soource Technologies 304.indd
P. 339

Unit 13: Extensible Markup Language



            if ($this->ends_record[$element]) {                                                   Notes
            $this->records[] = $this->record;
            $this->record = array( );

            }
            $this->current_field = ‘’;

            }
            function cdata ($p, $text) {
            if ($this->field_type[$this->current_field] === 2)
            {

            $this->record[$this->current_field][] = $text;
            }

            elseif ($this->field_type[$this->current_field] === 1) {
            $this->record[$this->current_field] .= $text;
            }
            }

            function show_menu( )
            {
            echo “<table border=1>\n”;

            foreach ($this->records as $book) {
            echo “<tr>”;
            $authors = join(‘, ‘, $book[‘author’]);

            printf(“<th><a  href=’%s’>%s</a></th><td>%s</td></tr>\n”,  $_SERVER[‘PHP_SELF’]  .
            ‘?isbn=’ . $book[‘isbn’], $book[‘title’], $authors);

            echo “</tr>\n”;
            }
            }

            function show_book ($isbn) {
            foreach ($this->records as $book)
            {

            if ($book[‘isbn’] !== $isbn)
            {
            continue;

            }
            $authors = join(‘, ‘, $book[‘author’]);
            printf(“<b>%s</b> by %s.<br>”, $book[‘title’], $authors);




                                             LOVELY PROFESSIONAL UNIVERSITY                                   333
   334   335   336   337   338   339   340   341   342   343   344