kellz Posted November 6, 2007 Share Posted November 6, 2007 hey.. I got myself into such a mess^^ All i wanted to do was make a random question in a drop menu thing and then place the questions in a random order into the drop menu with the answer to that question in a random place in the drop menu aswell, confused?.. it's such a messy script and it just...doesn't work! lol it's evil! beware <?php srand((float) microtime() * 10000000); $Q1='The water is in the '; $Q2='Open the '; $Q3='A animal with four legs '; $Q4='A person is a '; $Q5='A cat chases '; $Q=''; $S=''; $ANS = ''; $input = array("The water is in the ", "Open the ", "A animal with four legs", "A person is a ", "A cat chases "); $rnd = array_rand($input, 2); $Q=$input[$rnd[0]]; IF ($Q == $input[0]) $ANS = 'Sea'; IF ($Q == $input[1]) $ANS = 'Door'; IF ($Q == $input[2]) $ANS = 'Cat'; IF ($Q == $input[3]) $ANS = 'Human'; IF ($Q == $input[4]) $ANS = 'Mouse'; for ($i=0;$i < 6; $i++) { $arr = array("blue", "green", "orange", "purple", "white", "red", "gray", "yellow", "pink"); $rand = array_rand($arr, 2); $S.='<option>' . $arr[$rand[0]] . '</option> '; } $out = ''; $t = 0; $p=0; $pieces = explode(" ", $S); for ($i = 0; $i < 5; $i++) { $out .= $pieces[$i].'<br>'; while ($p < 100 && $t == 0) { if (rand(5, 10)==6) { $out .= ' ' . $ANS.'<br> '; echo $out; $t = 1; } } } $menu = <<<HERE <select> $out </select> HERE; echo $menu; ?> I was trying for like an hour and 30 minutes in my lunch break (im so anti-social) it's all PHP's fault!! I'm in my IT class now and I'm actually supposed to be doing work in excel but i hate it so much! lol ok he wont catch me *i hope*. Link to comment https://forums.phpfreaks.com/topic/76198-solved-omg-its-gotten-so-confusing/ Share on other sites More sharing options...
Psycho Posted November 6, 2007 Share Posted November 6, 2007 <html> <head></head> <body> <?php $results = array ( 'Sea' => 'The water is in the', 'Door' => 'Open the', 'Cat' => 'An animal with four legs', 'Human' => 'A person is a', 'Mouse' => 'A cat chases a' ); $questions = $results; shuffle($questions); $q_select = $_POST['question']; $answers = array_keys($results); shuffle($answers); $a_select = $_POST['answer']; echo "<form method=\"POST\">\n"; echo "Question: <select name=\"question\">\n"; foreach ($questions as $question) { $selected = ($q_select==$question) ? ' selected="selected"' : ''; echo " <option value=\"$question\"$selected>$question</option>/n"; } echo "</select><br>\n"; echo "Answer: <select name=\"answer\">\n"; foreach ($answers as $answer) { $selected = ($a_select==$answer) ? ' selected="selected"' : ''; echo " <option value=\"$answer\"$selected>$answer</option>/n"; } echo "</select><br><br>\n"; echo "<button type=\"submit\">Submit</button>\n"; echo "</form>\n"; if (!empty($q_select) && !empty($a_select)) { echo "Your response: \"$q_select $a_select\"<br><br>\n"; if ($results[$a_select]==$q_select) { echo "Correct answer."; } else { echo "Wrong answer, try again."; } } ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/76198-solved-omg-its-gotten-so-confusing/#findComment-385623 Share on other sites More sharing options...
kellz Posted November 6, 2007 Author Share Posted November 6, 2007 OMG your so clever and I'm so jealous and it's so totally unfair! you made it like 1000 lines shorter! now i feel bad because it's like i had to get someone else to do something for me instead of me doing it, you didn't have to waste your time doing all that but yesh it was nice of you <3 although I would be happy with hints or tips and .. stuff^^ Link to comment https://forums.phpfreaks.com/topic/76198-solved-omg-its-gotten-so-confusing/#findComment-385656 Share on other sites More sharing options...
beansandsausages Posted November 6, 2007 Share Posted November 6, 2007 Hey click topic solved if you been helped please. And OMG havent hear love you lots like jelly totts for years!!! Link to comment https://forums.phpfreaks.com/topic/76198-solved-omg-its-gotten-so-confusing/#findComment-385720 Share on other sites More sharing options...
Psycho Posted November 6, 2007 Share Posted November 6, 2007 Well, I had some difficulty trying to understand what you were trying to accomplish by looking at your code - I have no idea what the array of colors was for. So, I just wrote some code based upon your explanation. Rather than explain the code line-by-line, let me know if you have any specific questions and I can respond. Link to comment https://forums.phpfreaks.com/topic/76198-solved-omg-its-gotten-so-confusing/#findComment-385768 Share on other sites More sharing options...
revraz Posted November 6, 2007 Share Posted November 6, 2007 I LOL'd for real on that. And OMG havent hear love you lots like jelly totts for years!!! Link to comment https://forums.phpfreaks.com/topic/76198-solved-omg-its-gotten-so-confusing/#findComment-385776 Share on other sites More sharing options...
SirChick Posted November 6, 2007 Share Posted November 6, 2007 And OMG havent hear love you lots like jelly totts for years!!! I guess you have only seen it like this : echo 'love you lots like jelly jots'; or die (); Thats the only place I've seen it hehe Topic solved button is to the right >> Link to comment https://forums.phpfreaks.com/topic/76198-solved-omg-its-gotten-so-confusing/#findComment-385815 Share on other sites More sharing options...
kellz Posted November 6, 2007 Author Share Posted November 6, 2007 to revraz: don't LOL'd at me :'( to the person that told me to click "topic solved": will you go through a million posts and tell everyone else to do it too? it's not exactly solved yet, I might have another question about this, who knows?^^ to mjdamato: sry, I even confused myself and I don't know why i have colors there, they got there themself.. I really can't remember.. to santa: i want an nintendo ds for xmas and an ipod (i will also accept money for these items instead). Link to comment https://forums.phpfreaks.com/topic/76198-solved-omg-its-gotten-so-confusing/#findComment-385817 Share on other sites More sharing options...
SirChick Posted November 6, 2007 Share Posted November 6, 2007 to the person that told me to click "topic solved": will you go through a million posts and tell everyone else to do it too? it's not exactly solved yet, I might have another question about this, who knows?^^ then you make a new thread about your new problem... the people who dont topic solve tend to not get help if they develop a rep of not helping everyone else. Link to comment https://forums.phpfreaks.com/topic/76198-solved-omg-its-gotten-so-confusing/#findComment-385823 Share on other sites More sharing options...
beansandsausages Posted November 6, 2007 Share Posted November 6, 2007 Sorry i didnt mean to offend, i have some jelly tots for you. Link to comment https://forums.phpfreaks.com/topic/76198-solved-omg-its-gotten-so-confusing/#findComment-385837 Share on other sites More sharing options...
revraz Posted November 6, 2007 Share Posted November 6, 2007 I wasn't, I was laughing at Burnside poking fun at you Oh, and Santa doesn't give money. I've been trying for years to get it out of him. to revraz: don't LOL'd at me :'( to santa: i want an nintendo ds for xmas and an ipod (i will also accept money for these items instead). Link to comment https://forums.phpfreaks.com/topic/76198-solved-omg-its-gotten-so-confusing/#findComment-385841 Share on other sites More sharing options...
kellz Posted November 6, 2007 Author Share Posted November 6, 2007 Sorry i didnt mean to offend, i have some jelly tots for you. *takes the jelly tots and runs away with them*.. MINE ALL MINE! Link to comment https://forums.phpfreaks.com/topic/76198-solved-omg-its-gotten-so-confusing/#findComment-385890 Share on other sites More sharing options...
beansandsausages Posted November 6, 2007 Share Posted November 6, 2007 Haha i have loads more. Link to comment https://forums.phpfreaks.com/topic/76198-solved-omg-its-gotten-so-confusing/#findComment-385910 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.