Jump to content

cobusbo

Members
  • Posts

    224
  • Joined

  • Last visited

Posts posted by cobusbo

  1. Hi I'm trying to setup Pagination at the bottom of the page after showing 10 images in the following script but have no clue where to start and how to implement it into the script. 
     
    I also need some help to make a rule where images should show not bigger than 800 x 600 and. 
     
    Lastly I receive a line showing &nbsp at the bottom of the page and I have no Idea how to remove it... 
     
    <!DOCTYPE html> 
    <html> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html"> 
    <title>Show images in folder</title> 
    <link rel="stylesheet" type="text/css" href="style.css"> 
    </head> 
    <body> 
    <br> 
    <?php 
    date_default_timezone_set("Africa/Harare"); 
    $folder = 'img/'; 
    $filetype = '*.*'; 
    $files = glob($folder.$filetype); 
    $count = count($files); 
    
    $sortedArray = array(); 
    for ($i = 0; $i < $count; $i++) { 
        $sortedArray[date ('YmdHis', filemtime($files[$i])) . $i] = $files[$i]; 
    } 
    
    ksort($sortedArray); 
    # krsort($sortedArray); 
    
    echo '<table>'; 
    foreach ($sortedArray as &$filename) { 
        echo '<tr><td>'; 
        echo '<a name="'.$filename.'" <br><img src="'.$filename.'" /></a>'; 
    echo '<br>'; 
        echo substr($filename,strlen($folder),strpos($filename, '.')-strlen($folder)); 
        echo '</td></tr>'; 
    } 
    echo '</table>'; 
    ?>
    

     

  2. like this?

    <?php
    //test.php
    /* * *******Copyright (c) 2009 Ben Hall*********
    
      Permission is hereby granted, free of charge, to any person
      obtaining a copy of this software and associated documentation
      files (the "Software"), to deal in the Software without
      restriction, including without limitation the rights to use,
      copy, modify, merge, publish, distribute, sublicense, and/or sell
      copies of the Software, and to permit persons to whom the
      Software is furnished to do so, subject to the following
      conditions:
    
      The above copyright notice and this permission notice shall be
      included in all copies or substantial portions of the Software.
    
      THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
      EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
      OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
      NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
      HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
      WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
      OTHER DEALINGS IN THE SOFTWARE.
     */
    include 'functions.php';
    session_name("Simple-Quiz");
    $session = Session::get_instance();
    $num = isset($_SESSION['num']) ? $_SESSION['num'] : 0;
    require('res/questionsandanswers.php');
    $quiz = new Quiz($answers, $questions);
    ?>
    <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link rel="stylesheet" href="css/style.css" type="text/css" />
        <title>Rekeningkunde Vasvra</title>
        <?php
        if (!isset($_SESSION['last'])) {
            echo "<script type=\"text/javascript\" src=\"js/form.js\"></script>";
        }
        ?>
    </head>
    <body>
        <div id="wrapper">
            <div id="intro">
                <h1>Neem die toets en sien hoe goed ken U Sekere aspekte binne in Rente Berekening</h1>
                <p>Elke vraag het 4 opsies kies een en kliek op Gaan Voort om na volgende vraag te beweeg.</p>
                <p>Daar is 10 vrae om te voltooi en U uitslae sal teen die einde verskyn.</p>
                <?php if (isset($_SESSION['user'])) echo "<h4>Huidige Gebruiker: {$_SESSION['user']}</h4>"; ?>
            </div><!--intro-->
            <div id="quiz">
            <?php if (!isset($_SESSION['last'])) { ?>
                    <h2>Vraag <?php echo $num + 1; ?>:</h2>
                    <p><strong><?php echo $questions[$num]; ?></strong></p>
                    <form id="questionBox" method="post" action="processor.php">
    <ul>
      <?php
         public function shuffle_assoc($array) {
    
            $keys = array_keys($array);
            shuffle($keys);
            $shuffled = array();
            foreach ($keys as $key) {
                $shuffled[$key] = $array[$key];
            }
            foreach ($shuffled as $answer) {
                #$answer2 = str_replace($this->_pattern, $this->_replace, $answer);
                $option = $answer[0];
                $id = "answer$option";
                $this->_output .= "<li><input type=\"radio\" id=\"$id\" value=\"$option\" name=\"answers\" />\n";
                $this->_output .= "<label for=\"$id\">$answer</label></li>\n";
            }
            return $this->_output;
        }                   
                            ?>
    </ul>
    <p><input type="hidden" name="num" value="<?php echo $num; ?>" />
                            <input type="hidden" name="submitter" value="TRUE" />
                            <input type="submit" id="submit" name="submit" value="Gaan Voort" /></p>
                    </form>
                <?php
                } else {
                    echo $quiz->giveVerdict();
                }
                ?>
            </div><!--quiz-->
        </div><!--wrapper-->
    </body>
    </html>
    

     

    because now they say theres an error in line 60?

  3. Is this the part of code you guys need to help me fix this situation?

     

    <?php
    //test.php
    /* * *******Copyright (c) 2009 Ben Hall*********
    
      Permission is hereby granted, free of charge, to any person
      obtaining a copy of this software and associated documentation
      files (the "Software"), to deal in the Software without
      restriction, including without limitation the rights to use,
      copy, modify, merge, publish, distribute, sublicense, and/or sell
      copies of the Software, and to permit persons to whom the
      Software is furnished to do so, subject to the following
      conditions:
    
      The above copyright notice and this permission notice shall be
      included in all copies or substantial portions of the Software.
    
      THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
      EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
      OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
      NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
      HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
      WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
      OTHER DEALINGS IN THE SOFTWARE.
     */
    include 'functions.php';
    session_name("Simple-Quiz");
    $session = Session::get_instance();
    $num = isset($_SESSION['num']) ? $_SESSION['num'] : 0;
    require('res/questionsandanswers.php');
    $quiz = new Quiz($answers, $questions);
    ?>
    <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link rel="stylesheet" href="css/style.css" type="text/css" />
        <title>Rekeningkunde Vasvra</title>
        <?php
        if (!isset($_SESSION['last'])) {
            echo "<script type=\"text/javascript\" src=\"js/form.js\"></script>";
        }
        ?>
    </head>
    <body>
        <div id="wrapper">
            <div id="intro">
                <h1>Neem die toets en sien hoe goed ken U Sekere aspekte binne in Rente Berekening</h1>
                <p>Elke vraag het 4 opsies kies een en kliek op Gaan Voort om na volgende vraag te beweeg.</p>
                <p>Daar is 10 vrae om te voltooi en U uitslae sal teen die einde verskyn.</p>
                <?php if (isset($_SESSION['user'])) echo "<h4>Huidige Gebruiker: {$_SESSION['user']}</h4>"; ?>
            </div><!--intro-->
            <div id="quiz">
            <?php if (!isset($_SESSION['last'])) { ?>
                    <h2>Vraag <?php echo $num + 1; ?>:</h2>
                    <p><strong><?php echo $questions[$num]; ?></strong></p>
                    <form id="questionBox" method="post" action="processor.php">
                        <ul>
                            <?php
                            echo $quiz->shuffle_assoc($answers[$num]);
                            ?>
                        </ul>
                        <p><input type="hidden" name="num" value="<?php echo $num; ?>" />
                            <input type="hidden" name="submitter" value="TRUE" />
                            <input type="submit" id="submit" name="submit" value="Gaan Voort" /></p>
                    </form>
                <?php
                } else {
                    echo $quiz->giveVerdict();
                }
                ?>
            </div><!--quiz-->
        </div><!--wrapper-->
    </body>
    </html>
    
  4. The thing is Im using a script I downloaded from Sourceforge and Im just trying to edit it to fit my needs and trying to change the structure wont fit in its layout im using the script im using can be found here so im trying to fit my needs for my Website

     

    I agree changing the structure will be a good Idea but I don't have the knowledge to trans code it so it fit with the other part of the coding structure. So im just trying to do the best of a bad situation and modify the basics for now so the problem can be resolved. The thing is these radio boxes works it would had been just been more neat if it didn't pop up the unnecessary coding

     

    Thank you for all the support so far Barnard I appreciate your patience.

  5. Place the img tag after the radio input tag, not inside it.

    but if I do so then it won't pop up as the radio option? see post #1 I placed it in the array so it can auto select wich one is correct if I move it out of there it will not pop up for that question only? Or should I make the 4 pictures 1 picture with options A B C and D and place it in the Question and Just place The options ABCD as the options for the radio input tag?

  6. Definitely your other script is the problem. You are including the image as a "name" for the checkbox. You'll need to post or fix the other script.

    Well the A B or D I just tried to put in text to see if it didnt fix the problem with the 

    
    
    " value="D_" name="answers" /> ">D
    

    showing up if I put in normal text there is no problem but as soon as I put the img_src code the above appears. what should I fix because im lost dont know where to start. I want to place the images as options to select from

     

    <?php //processor.php
    /*********Copyright (c) 2009 Ben Hall*********
    
    Permission is hereby granted, free of charge, to any person
    obtaining a copy of this software and associated documentation
    files (the "Software"), to deal in the Software without
    restriction, including without limitation the rights to use,
    copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the
    Software is furnished to do so, subject to the following
    conditions:
    
    The above copyright notice and this permission notice shall be
    included in all copies or substantial portions of the Software.
    
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
    OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
    HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
    WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
    OTHER DEALINGS IN THE SOFTWARE.
     */
    include 'functions.php';
    session_name("Simple-Quiz");
    $session = Session::get_instance();
    require('res/questionsandanswers.php');
    $quiz = new Quiz($answers, $questions);
    if (!isset($_POST['submitter'])) {
    
        if (isset($_POST['register'])) {
            $quiz->registerUser();
        } else {
            $quiz->createRandomUser();
        }
    } else {
        
        $_SESSION['num'] = (int) $_POST['num'];
        $num = $_SESSION['num'];
        $postedanswers = str_replace("_", " ", $_POST['answers']);
        if ($postedanswers == $answers[$num]['0']) {
            $_SESSION['score']++;
            $_SESSION['correct'][] = $postedanswers;
        } else {
            $_SESSION['wrong'][] = $postedanswers;
        }
        if ($_SESSION['num'] < count($questions) - 1) {
            $_SESSION['num']++;
        } else {
            $_SESSION['last'] = true;
            $_SESSION['finished'] = 'yes';
        }
        header('Location: test.php');
    }
    ?>
    

  7. <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" href="css/style.css" type="text/css" />
    <title>Rekeningkunde Vasvra</title>
    <script type="text/javascript" src="js/form.js"></script></head>
    <body>
    <div id="wrapper">
    <div id="intro">
    <h1>Neem die toets en sien hoe goed ken U Sekere aspekte binne Ontleding van Transaksies</h1>
    <p>Elke vraag het 4 opsies kies een en kliek op Gaan Voort om na volgende vraag te beweeg.</p>
    <p>Daar is 10 vrae om te voltooi en U uitslae sal teen die einde verskyn.</p>
    <h4>Huidige Gebruiker: Anon865</h4> </div><!--intro-->
    <div id="quiz">
    <h2>Vraag 5:</h2>
    <p><strong>‘n Tjek van R2 000 ontvang van Z. Kotzé vir goedere op skuld gekoop is deur die bank geweier. Wat sal die invloed van die transaksie wees op die eienaarsbelang?</strong></p>
    <form id="questionBox" method="post" action="processor.php">
    <ul>
    <li><input type="radio" id="D_<img_src="http://rekvasvra.uni.me/img/otable2vr5d.jpg"_width="239"_height="79"_name="D"_longdesc="http://rekvasvra.uni.me/img/"_/>" value="D_<img_src="http://rekvasvra.uni.me/img/otable2vr5d.jpg"_width="239"_height="79"_name="D"_longdesc="http://rekvasvra.uni.me/img/"_/>" name="answers" />
    <label for="D_<img_src="http://rekvasvra.uni.me/img/otable2vr5d.jpg"_width="239"_height="79"_name="D"_longdesc="http://rekvasvra.uni.me/img/"_/>">D <img src="http://rekvasvra.uni.me/img/otable2vr5d.jpg" width="239" height="79" name="D" longdesc="http://rekvasvra.uni.me/img/" /></label></li>
    <li><input type="radio" id="A
    <img_src="http://rekvasvra.uni.me/img/otable2vr5a.jpg"_width="239"_height="79"_name="A"__longdesc="http://rekvasvra.uni.me/img/"_/>" value="A
    <img_src="http://rekvasvra.uni.me/img/otable2vr5a.jpg"_width="239"_height="79"_name="A"__longdesc="http://rekvasvra.uni.me/img/"_/>" name="answers" />
    <label for="A
    <img_src="http://rekvasvra.uni.me/img/otable2vr5a.jpg"_width="239"_height="79"_name="A"__longdesc="http://rekvasvra.uni.me/img/"_/>">A
    <img src="http://rekvasvra.uni.me/img/otable2vr5a.jpg" width="239" height="79" name="A" longdesc="http://rekvasvra.uni.me/img/" /></label></li>
    <li><input type="radio" id="B
    <img_src="http://rekvasvra.uni.me/img/otable2vr5b.jpg"_width="239"_height="79"_name="B"_longdesc="http://rekvasvra.uni.me/img/"_/>" value="B
    <img_src="http://rekvasvra.uni.me/img/otable2vr5b.jpg"_width="239"_height="79"_name="B"_longdesc="http://rekvasvra.uni.me/img/"_/>" name="answers" />
    <label for="B
    <img_src="http://rekvasvra.uni.me/img/otable2vr5b.jpg"_width="239"_height="79"_name="B"_longdesc="http://rekvasvra.uni.me/img/"_/>">B
    <img src="http://rekvasvra.uni.me/img/otable2vr5b.jpg" width="239" height="79" name="B" longdesc="http://rekvasvra.uni.me/img/" /></label></li>
    <li><input type="radio" id="C_
    <img_src="http://rekvasvra.uni.me/img/otable2vr5c.jpg"_width="239"_height="79"_name="C"
    longdesc="http://rekvasvra.uni.me/img/"_/>" value="C_
    <img_src="http://rekvasvra.uni.me/img/otable2vr5c.jpg"_width="239"_height="79"_name="C"
    longdesc="http://rekvasvra.uni.me/img/"_/>" name="answers" />
    <label for="C_
    <img_src="http://rekvasvra.uni.me/img/otable2vr5c.jpg"_width="239"_height="79"_name="C"
    longdesc="http://rekvasvra.uni.me/img/"_/>">C
    <img src="http://rekvasvra.uni.me/img/otable2vr5c.jpg" width="239" height="79" name="C"
    longdesc="http://rekvasvra.uni.me/img/" /></label></li>
    </ul>
    <p><input type="hidden" name="num" value="4" />
    <input type="hidden" name="submitter" value="TRUE" />
    <input type="submit" id="submit" name="submit" value="Gaan Voort" /></p>
    </form>
    </div><!--quiz-->
    </div><!--wrapper-->
    </body>
    </html>
     
  8. ok so wich document do you need to get to see what is wrong because normal text works but as soon as I place the img in there I get such an result dont know if this will help?

     

    <?php
    /**
     * Description of Quiz
     *
     * @author ben
     */
    class Quiz {
    
        private $_answers;
        private $_questions;
        private $_leaders = array();
        private $_formattedAnswers = '';
        private $_leaderboard;
        private $_xml;
        private $_verdict = '';
        private $_output = '';
        private $_pattern = ' ';
        private $_replace = '_';
    
        public function __construct(array $answers, array $questions) {
            try {
                // need to have singleton db class that pulls specific quiz info from db based on quiz name params
                $this->_answers = $answers;
                $this->_questions = $questions;
                $this->_xml = simplexml_load_file(config::$leaderboardfile);
            } catch (Exception $e) {
                echo $e->getMessage();
            }
        }
        
        public function shuffle_assoc($array) {
    
            $keys = array_keys($array);
            shuffle($keys);
            $shuffled = array();
            foreach ($keys as $key) {
                $shuffled[$key] = $array[$key];
            }
            foreach ($shuffled as $answer) {
                $answer2 = str_replace($this->_pattern, $this->_replace, $answer);
                $this->_output .= "<li><input type=\"radio\" id=\"$answer2\" value=\"$answer2\" name=\"answers\" />\n";
                $this->_output .= "<label for=\"$answer2\">$answer</label></li>\n";
            }
            return $this->_output;
        }
        
        public function registerUser() {
            $username = trim(strip_tags(stripslashes($_POST['username'])));
            foreach ($this->_xml->user as $user) {
                if ($user->name == $username) {
                    $_SESSION['error'] = 'U gebruikersnaam is alreeds gebruik.';
                    header('Location: index.php');
                    exit();
                }
            }
            $_SESSION['user'] = $username;
            $_SESSION['score'] = 0;
            $_SESSION['correct'] = array();
            $_SESSION['wrong'] = array();
            $_SESSION['finished'] = 'no';
            if (isset($_SESSION['error']))
                unset($_SESSION['error']);
            $_SESSION['num'] = 0;
            header('Location: test.php');
        }
        
        public function createRandomUser() {
            $random = rand(1,1000);
            $_SESSION['user'] = 'Anon' . $random;
            $_SESSION['score'] = 0;
            $_SESSION['correct'] = array();
            $_SESSION['wrong'] = array();
            $_SESSION['finished'] = 'no';
            $_SESSION['num'] = 0;
            header('Location: test.php');
        }
        
        public function giveVerdict() {
            $user = $this->_xml->addChild('user');
            $uname = $user->addChild('name', $_SESSION['user']);
            $uscore = $user->addChild('score', $_SESSION['score']);
            $this->_xml->asXML(Config::$leaderboardfile);
    
            $this->_verdict .= "<h2 id=\"score\">{$_SESSION['user']}, Jou finale uitslag is: </h2>\n
     <h3>{$_SESSION['score']}/10</h3><h4>Kommentaar:</h4>";
            if ($_SESSION['score'] <= 5) {
                $this->_verdict .= "<p id=\"verdict\"><span>S</span>everely <span>H</span>indered <span>I</span>n the <span>T</span>est!</p>\n";
            }
            if (($_SESSION['score'] <= 6)) {
                $this->_verdict .= "<p id=\"verdict\"><span>C</span>ould <span>R</span>ead <span>A</span>nd <span>P</span>ractice more.</p>\n";
            }
            if (($_SESSION['score'] >= 7) ) {
                $this->_verdict .= "<p id=\"verdict\"><span>A</span>ccountings a<span>R</span>e <span>S</span>o <span>E</span>asy!</p>\n";
            }
            if ($_SESSION['score'] >=  {
                $this->_verdict .= "<p id=\"verdict\"><span>S</span>uper <span>A</span>ccounting <span>S</span>pecialist</p>";
            }
            $this->_verdict .= "<p id=\"compare\"><a href=\"results.php\">Sien hoe vergelyk jy! <img src=\"images/arrow.png\" /></a></p>";
            
            return $this->_verdict;
        }
    
        public function showLeaders($limit, $group = null) {
    
            // Place all users and associated 
            // scores into the 'leaders' array.
            foreach ($this->_xml->user as $user) {
                $name = (string) $user->name;
                $score = (string) $user->score;
                $this->_leaders[$name] = $score;
            }
    
            // Sort the leaders array numerically, highest scorers first.	
            arsort($this->_leaders, SORT_NUMERIC);
    
            // Initialise our $counter variable to '1'.
            $counter = 1;
    
            // Start a html ordered list to hold the leaders.
            $this->_leaderboard = "<ul class=\"leaders\">\n";
    
            // Loop through the 'leaders' array and wrap each username and score
            // in <li> tags. If the user is the current $_SESSION['user'], wrap
            // the name/score in <strong> tags too.
            foreach ($this->_leaders as $key => $value) {
                // Check that $counter is less than $limit.
                if ($counter <= $limit) {
                    if ( (isset($_SESSION['user'])) && ($key == $_SESSION['user']) ) {
                        $this->_leaderboard .= "<li><strong>$key:</strong> $value/". count($this->_questions) ."</li>\n";
                    } else {
                        $this->_leaderboard .= "<li>$key: $value/". count($this->_questions) ."</li>\n";
                    }
                    // Check to see if $group parameter has been passed.
                    // If it has, create separate lists according to the $group variable.
                    if ($group) {
                        // Use the modulus operator(%) to create new sub-list if required.
                        if ( ($counter % $group == 0) && ($counter != $limit ) ) {
                            $this->_leaderboard .= "</ul>\n<ul class=\"leaders\">\n";
                        }
                    }
                }
                // Increment the $counter.	
                $counter++;
            }
            // End the ordered list.
            $this->_leaderboard .= "</ul>\n";
    
            // return the ordered list.
            return $this->_leaderboard;
        }
    
        public function formatAnswers() {
            for ($x = 0; $x < count($this->_answers); $x++) {
                if ($x % 2 == 0) {
                    $this->_formattedAnswers .= "<div class=\"qanda clear\">\n";
                } else {
                    $this->_formattedAnswers .= "<div class=\"qanda\">";
                }
                $this->_formattedAnswers .= '<h4>Vraag ' . ($x + 1) . ': ' . $this->_questions[$x] . '</h4>';
                $this->_formattedAnswers .= "<ol>\n";
                for ($y = 0; $y < count($this->_answers[$x]); $y++) {
                    if (($this->_answers[$x][$y] === $this->_answers[$x][0]) && (in_array($this->_answers[$x][$y], $_SESSION['correct']))) {
                        $this->_formattedAnswers .= "<li class=\"correctuser\">{$this->_answers[$x][$y]} (Korrek!)</li>\n";
                    } else if ($this->_answers[$x][$y] === $this->_answers[$x][0]) {
                        $this->_formattedAnswers .= "<li class=\"correct\">{$this->_answers[$x][$y]}</li>\n";
                    } else if (in_array($this->_answers[$x][$y], $_SESSION['wrong'])) {
                        $this->_formattedAnswers .= "<li class=\"wrong\">{$this->_answers[$x][$y]} (Eina!)</li>\n";
                    } else {
                        $this->_formattedAnswers .= "<li>{$this->_answers[$x][$y]}</li>\n";
                    }
                }
                $this->_formattedAnswers .= "</ol></div>\n";
                
            }
            return $this->_formattedAnswers;
        }
    
    }
    ?>
    
  9. Hi guys im using the following code
    Code:

    
    
    
    
    <?php
    $questions = array('Op 5 Julie 2008 betaal Johan Steyn sy werknemers se weeklikse lone deur ‘n tjek vir R7 500 te wissel.*Watter twee algemene grootboek rekeninge sal gebruik word?','Ontvang ‘n tjek van C. Botha om sy rekening van R2 000 te vereffen; korting toegestaan is 5%.*Verduidelik wat gebeur met jou rekenkundige vergelyking. (Bankrekening is oortrokke)','Koop handelsware op krediet aan van Smit Traders vir R600 minus 10% korting.*Hoeveel gaan die handelsvoorraad nou kos?','Verkoop goedere op krediet aan E. Van der Merwe vir R500 (kosprys R200).*Watter van die volgende is waar?','‘n Tjek van R2 000 ontvang van Z. Kotzé vir goedere op skuld gekoop is deur die bank geweier.*Wat sal die invloed van die transaksie wees op die eienaarsbelang?','Watter een van die volgende transaksies sal pas by :<img src="http://rekvasvra.uni.me/img/table1vr6.jpg" width="239" height="79" longdesc="http://rekvasvra.uni.me/img/" />','Die eienaar S. Swart verhoog sy belang in die onderneming deur ‘n tjek van R50 000 te gee vir kapitaalbydrae.*Watter een van die volgende sal die regte inskrywing wees?','Skep ‘n voorsiening vir oninbare skulde teen 5%. (Debiteure is R40 000) Watter een is korrek? ','Watter een van die volgende transaksies sal pas by:<img src="http://rekvasvra.uni.me/img/table4vr9.jpg" width="239" height="79" longdesc="http://rekvasvra.uni.me/img/" />','Bereken die waardevermindering van die besigheidsvoertuig.*Drawaarde is R100 000 en die opgelope waardevermindering is R20 000.*(waardevermindering word op die verminderde saldo bereken teen 15%)*Wat is die waardevermindering?');
    $answers = array(
    // the correct answer for each question must be the first array item 0=>'item'
    array(0 =>'Bank en Lone','Bank en Salarisse','Debiteure Kontrole en Lone','Kleinkas en Lone'),
    array(0 => 'Bates – R2 000; Eienaarsbelang – R100;*Laste – R1 900','Bates – R2 000; Eienaarsbelang + R100;*Laste – R1 900','Bates – R2 000; Eienaarsbelang – R100;*Laste + R1 900','Bates + R2 000; Eienaarsbelang – R100;*Laste – R1 900'),
    array(0 => 'R540','R60','R660','R600'),
    array(0 => 'Debiteure + R500; Handelsvoorraad – R200','Debiteure + R500; Handelsvoorraad + R200','Krediteure + R500; Handelsvoorraad – R200','Krediteure + R500; Handelsvoorraad + R200'),
    array(0 => 'A
    <img src="http://rekvasvra.uni.me/img/otable2vr5a.jpg" width="239" height="79" name="A" longdesc="http://rekvasvra.uni.me/img/" />','B
    <img src="http://rekvasvra.uni.me/img/otable2vr5b.jpg" width="239" height="79" name="B" longdesc="http://rekvasvra.uni.me/img/" />','C
    <img src="http://rekvasvra.uni.me/img/otable2vr5c.jpg" width="239" height="79" name="C"
    longdesc="http://rekvasvra.uni.me/img/" />','D <img src="http://rekvasvra.uni.me/img/otable2vr5d.jpg" width="239" height="79" name="D" longdesc="http://rekvasvra.uni.me/img/" />'),
    array(0 => 'Huur ‘n gebou van Seeff eiendomme en betaal die huur per tjek, R1000','Betaal R10 000 kontant aan huuruitgawes','Ontvang R1000 vir perseel wat uit verhuur word','Die huuruitgawe het opgeloop en is agterstallig met ‘n R1000'),
    array(0 => 'Kapitaal gekrediteer met R50 000; Bank gedebiteer met R50 000','Kapitaal gekrediteer met R50 000; Onttrekkings gedebiteer met R50 000','Bank gekrediteer met R50 000; Kapitaal gedebiteer met R50 000','Bank gedebiteer met R50 000; Kapitaal gedebiteer met R50 000'),
    array(0 => 'A
    <img src="http://rekvasvra.uni.me/img/otable3vr8a.jpg" width="239" height="79" name="A" longdesc="http://rekvasvra.uni.me/img/" />','B
    <img src="http://rekvasvra.uni.me/img/otable3vr8b.jpg" width="239" height="79" name="B" longdesc="http://rekvasvra.uni.me/img/" />','C
    <img src="http://rekvasvra.uni.me/img/otable3vr8c.jpg" width="239" height="79" name="C" longdesc="http://rekvasvra.uni.me/img/" />','D
    <img src="http://rekvasvra.uni.me/img/otable3vr8d.jpg" width="239" height="79" name="D" longdesc="http://rekvasvra.uni.me/img/" />'),
    array(0 => 'Wissel ‘n kontant tjek en betaal die lone van R800','Eienaar ontvang sy loon van R800','Wissel ‘n kontant tjek en betaal salarisse van R800','Eienaar verhoog sy kapitaal bydrae met R800'),
    array(0 => 'R12 000','R11 000','R1 200','R15 000'),
    );
    ?>
    

     


    but im experiencing an error if I use the image links in the array if I load the page it appears as follow

    post-141539-0-58766300-1362313315_thumb.jpg

    can someone please help my edit this code to fix the problem not to show the tags above the image

  10. Ok I found the solution but theres something else that is bugging me now

    <?php
    
    $retriever = new DOMDocument();
    
    $retriever ->load( 'res/leaders.xml' );
    
    $masterElement = $retriever->documentElement;
    
    $masterContent = $masterElement->getElementsByTagName('user')->item(0);
    
    $oldContent = $masterElement->removeChild($masterContent );
    
    echo $retriever->saveXML();
    echo $retriever->save( 'res/leaders.xml' );
    ?>
    

     

    This delete each record as I refresh it each time, isnt there a way to delete all at once or create a table where I can tick off to delete each record? and after I deleted all the records isn't there a way to tell me there are no more records and link me back to the index? in place of getting the error

    Catchable fatal error: Argument 1 passed to DOMNode::removeChild() must be an instance of DOMNode, null given in /srv/disk1/1296487/www/rekvasvra.uni.me/Gr10/Rente/cron.php on line 23 when all records are deleted

  11. Thank you but it shows the records after you run it but how do you delete it?

     

    and secondly if I look at your script part

    require_once("DOMe.php");
        
        $dom = new DOMe("");
        $dom->importHTML(file_get_contents("file2.html"));
    
    

    why do you open 2 files DOMe.php and get the file contents from file2.html, what is in both documents because at the moment I only got my leaders.xml file and a file named cron.php to delete my records.

     

    Here's how you could use the original script I posted. Example results at: http://tomsfreelance.com/DOMe/DOM_Import2.php (view the source to view the xml output)

     

    
    
    <?php
        require_once("DOMe.php");
        
        $dom = new DOMe("");
        $dom->importHTML(file_get_contents("file2.html"));
        
        echo $dom->generate();
        
        $users = $dom->getElementsByTagName("users");
        
        
        $data = array();
        foreach ($users as &$userGroup) {
            $elements = $userGroup->getElementsByTagName("user");
            foreach ($elements as $user) {
                $userGroup->remove($user);
            }
        }
        
        echo $dom->generate();
    
    
  12. Ok I see I tried it and gets the result, but it doesn't seem to remove the info, and is there a method to delete all records and not each one seperately because its difficult to determine how many there will be...

    Skuilnaam110cobus5cobusbo4

    This is trying to find all <users> elements that are descendants of the $masterElement. The $masterElement is representing the single <users> element that wraps the whole document: it has no descendant <users> elements, only <user>, <name>, and <score> elements.

    It looks like you wanted to use $masterElement->getElementsByTagName('user').

    Then you used ->item(3). Your XML document has three <user> elements so, assuming you change the call to getElementsByTagname() as shown above, you could access those via item(0), item(1), and item(2) respectively. There is no fourth <user> element to get using item(3).

    It looks like you wanted to use ->item(2).

    So given those changes to that one line of code, the code posted in post #5 above would work (it would delete the cobus user) and would not present an error. Could you give it a try and let us know how you get on? :shy:

  13.  then it gives me this result

    object(DOMNodeList)#3 (1) { ["length"]=> int(0) }
    Catchable fatal error: Argument 1 passed to DOMNode::removeChild() must be an instance of DOMNode, null given in /srv/disk1/1296487/www/rekvasvra.uni.me/Gr10/Rente/cron.php on line 24

    If you add var_dump ($masterElement->getElementsByTagName('users')); just before the line with the error, what do you get?

  14. this is what I got so far

     

    my leaders.xml document

    <?xml version="1.0" encoding="UTF-8"?>
    <users>
     <user><name>Skuilnaam</name><score>8</score></user><user><name>Skuilnaam1</name><score>10</score></user><user><name>cobus</name><score>5</score></user></users>
    
    

     

    and here i got my file which i want to run to delete my database entries and cleaning the xml entries but im have  problem with my xml deletion part

     

    <? 
     $db_host = "xxxxxxxxxxx";
     $db_user = "xxxxxxxxxxxx";
     $db_pass = "xxxxxxxxxxxxxx";
     $db_name = "xxxxxxxxxxx";
     $connect = @mysql_connect($db_host,$db_user,$db_pass);
     @mysql_select_db($db_name);
    static $leaderboardfile = 'res/leaders.xml';
     // Empty table
     $query = "TRUNCATE TABLE rente";
     mysql_query($query);
     ?>
    <?php
    
    $retriever = new DOMDocument();
    
    $retriever ->load( 'res/leaders.xml' );
    
    $masterElement = $retriever->documentElement;
    
    $masterContent = $masterElement->getElementsByTagName('users')->item(3);
    
    $oldContent = $masterElement->removeChild($masterContent );
    
    echo $retriever->saveXML();
    
    ?>
    
    

     

    I get the following error message:

    Catchable fatal error: Argument 1 passed to DOMNode::removeChild() must be an instance of DOMNode, null given in /srv/disk1/1296487/www/rekvasvra.uni.me/Gr10/Rente/cron.php on line 23

    can you guys please assist me with this error

  15. to be honest I have no idea where to start, ive been googling and found examples like these ones

    <?php 
    $xml = '<root>
      <featured>
        <title></title>
        <tweet></tweet>
        <img></img>
      </featured>
    </root>';    
    $dom = new DOMDocument();
    $dom->loadXML($xml);
    $featuredde1 = $dom->getElementsByTagName('featured');
    
    foreach ($featuredde1 as $node) {
        $node->parentNode->removeChild($node);
    }
    echo $dom->saveXML();
    
    The output is:
    <?xml version="1.0"?>
    <root>
    
    </root>
    

     

    but im not sure how to modify it for my needs, im a beginner and still learning the basics

  16. Hi I have this document 

    <?xml version="1.0" encoding="UTF-8"?>
    <users>
     <user><name>Skuilnaam</name><score>8</score></user><user><name>Skuilnaam1</name><score>10</score></user><user><name>cobus</name><score>5</score></user></users>
    
    

     

    I need help to make a php script that will delete the records inside this page for  me can anyone help me to construct such a page please?

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.