Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [wolontariat]PHP losowy quiz
Forum PHP.pl > Inne > Giełda ofert > Poszukuję
Lewy1337
Witam, pierwszy raz zabrałem się za stworzenie strony w PHP, gdyż muszę ją przygotować do szkoły, niestety nie znam nawet podstawowych komend ale potrzebuję rozwiązania na piątek i nie mam aktualnie zbytnio czasu żeby zagłębić się w tym temacie smile.gif Mógłby mi ktoś powiedzieć jak zrobić abym nie miał 2 wersji quizu tylko jedną wybraną ? Chciałbym mieć tylko jeden quiz stały ale nie wiem na co zmienić $rid = rand(1,2); smile.gif
Kod
<html>
<head>
<style type='text/css'>
#quiz {
    
    width:950px;
     height:auto;
     padding: 13px;
     margin-right:auto;
     margin-left:auto;
     background-color:#fff;
    
}
</style>
</head>

<body bgcolor='#e1e1e1'>

<?php

    $rid = rand(1,2);
    echo $rid;
?>

<div id='quiz'>

<center><font face='Andalus' size='5'><b>Quiz sieci Wi-Fi<br>wykonany przez<br>ssssi</b></font></center>
<br />
<br />
<br /><br />

<?php

if ($rid == 1){
    
    echo "
<form action='process.php?id=1' method='post' id='quizForm' id='1'>


    <ol>
    
  
        <li>
        <h3>Golec to</h3>
        
        <div>
        <label for='answer1'>Golec ma na imię </label><input type='text' name='answerOne' id='answerOne' value='' />
        
        </div>
        </li>
        
    
        <li>
        <h3>Podlaś</h3>
        
        <div>
        <input type='radio' name='answerTwo' id='answerTwo' value='A' />
        <label for='answerTwoA'>A)Piotrek</label>
        </div>
        
        <div>
        <input type='radio' name='answerTwo' id='answerTwo' value='B' />
        <label for='answerTwoB'>B)Dawid</label>
        </div>
        
        <div>
        <input type='radio' name='answerTwo' id='answerTwo' value='C' />
        <label for='answerTwoC'>C)Adi</label>
        </div>
        </li>
        
      
        
         <li>
        <h3>Pala</h3>
        
        <div>
        <input type='radio' name='answerThree' id='answerThree' value='A' />
        <label for='answerThreeA'>A)Marceli </label>
        </div>
        
        <div>
        <input type='radio' name='answerThree' id='answerThree' value='B' />
        <label for='answerThreeB'>B) Michał</label>
        </div>
        
        <div>
        <input type='radio' name='answerThree' id='answerThree' value='C' />
        <label for='answerThreeC'>C) Adam</label>
        </div>
        </li>
    </ol>
     <input type='submit' value='Submit Quiz' />
    
</form>";

}

if ($rid == 2){
    
    echo "


<form action='process.php?id=2' method='post' id='quizForm' id='2'>


    <ol>
    
    
        <li>
        <h3>3</h3>
        
        <div>
        <input type='radio' name='answerOne' id='answerOne' value='A' />
        <label for='answerOneA'>A)Cascading Style Sheet</label>
        </div>
        
        <div>
        <input type='radio' name='answerOne' id='answerOne' value='B' />
        <label for='answerOneB'>B) Hyper turn mark lingo</label>
        </div>
        
        <div>
        <input type='radio' name='answerOne' id='answerOne' value='C' />
        <label for='answerOneC'>C) Happy tissue mahatma life</label>
        </div>
        </li>
        
      
        <li>
        <h3>2</h3>
        
        <div>
        <input type='radio' name='answerTwo' id='answerTwo' value='A' />
        <label for='answerTwoA'>A)Video sharing website </label>
        </div>
        
        <div>
        <input type='radio' name='answerTwo' id='answerTwo' value='B' />
        <label for='answerTwoB'>B)A Search Engine</label>
        </div>
        
        <div>
        <input type='radio' name='answerTwo' id='answerTwo' value='C' />
        <label for='answerTwoC'>C) None of the above</label>
        </div>
        </li>
        
      
         <li>
        <h3>1</h3>
        
        <div>
        <input type='radio' name='answerThree' id='answerThree' value='A' />
        <label for='answerThreeA'>A)No One </label>
        </div>
        
        <div>
        <input type='radio' name='answerThree' id='answerThree' value='B' />
        <label for='answerThreeB'>B)Akon</label>
        </div>
        
        <div>
        <input type='radio' name='answerThree' id='answerThree' value='C' />
        <label for='answerThreeC'>C)Barack Hussain Obama </label>
        </div>
        </li>
    </ol>
     <input type='submit' value='Submit Quiz' />
    
</form>
";
}

?>
</div>

</body>
</html>
topcio
Pokombinuj z tym, nie jest to mojego autorstwa (znalezione w sieci), ale może się przydać.

  1. // inicjujemy generator licz losowych
  2. ((float)microtime()*1000000);
  3.  
  4. // tablica zawierajaca tablice z opisem i adresem
  5. $link[] = array('WP' => 'wp.pl');
  6. $link[] = array('Onet' => 'onet.pl');
  7. $link[] = array('Interia' => 'interia.pl');
  8. $link[] = array('Helion' => 'helion.pl');
  9. $link[] = array('KESS' => 'kess.com.pl');
  10.  
  11. // wybieramy losowy element z tablicy
  12. $linki_rand = $link[array_rand($link)];
  13.  
  14. // wyswietlamy gotowy link
  15. foreach($linki_rand as $key => $value) {
  16. echo "<a href=\"http://$value\">$key</a><br />";
  17. }
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.