oriental_express Posted December 11, 2008 Author Share Posted December 11, 2008 No... I mean, that's where you should use one of them. Like: "It's your big chance, your five minutes!" lol ok ok i get it now. Too focused on php kinda forgetten my sense of humour. Last time we discussed that the page can call upon itself if I leave the form action blank <FORM action="" method="post"> Would you say I just open some php tags perhaps up above the form and attempt to code it ? like so <?php ?> <FORM action="" method="post"> Quote Link to comment https://forums.phpfreaks.com/topic/134533-final-year-project-please-point-me-in-the-right-direction/page/4/#findComment-713132 Share on other sites More sharing options...
Mchl Posted December 11, 2008 Share Posted December 11, 2008 Yeah. That's good idea. Have all (or most) of your script at the beginning of your file, and html at the bottom. This way you're less prone to make errors. Quote Link to comment https://forums.phpfreaks.com/topic/134533-final-year-project-please-point-me-in-the-right-direction/page/4/#findComment-713137 Share on other sites More sharing options...
oriental_express Posted December 11, 2008 Author Share Posted December 11, 2008 Yeah. That's good idea. Have all (or most) of your script at the beginning of your file, and html at the bottom. This way you're less prone to make errors. Ok ok let me see what I can do. I'll probably come back with some cowboy code or something ... anyways here goes (into the unknown) Thanks for your support. Quote Link to comment https://forums.phpfreaks.com/topic/134533-final-year-project-please-point-me-in-the-right-direction/page/4/#findComment-713145 Share on other sites More sharing options...
oriental_express Posted December 13, 2008 Author Share Posted December 13, 2008 Hi again for some reason this does not work for me <?php if ($quest[$1] [3] == $_POST['ans']){ $i = $i + 1; } elseif ($quest[$1][5] == $_POST['ans']){ $i = $i + 2; I get this Parse error: syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' in C:\wamp\www\Tree\tree.php on line 19 any ideas without tell me the answer yet ? thanks } ?> Quote Link to comment https://forums.phpfreaks.com/topic/134533-final-year-project-please-point-me-in-the-right-direction/page/4/#findComment-714720 Share on other sites More sharing options...
Mchl Posted December 13, 2008 Share Posted December 13, 2008 if ($quest[$1] [3] == $_POST['ans']){ You sure you want $1 here? Quote Link to comment https://forums.phpfreaks.com/topic/134533-final-year-project-please-point-me-in-the-right-direction/page/4/#findComment-714739 Share on other sites More sharing options...
oriental_express Posted December 13, 2008 Author Share Posted December 13, 2008 if ($quest[$1] [3] == $_POST['ans']){ You sure you want $1 here? Yes sorry I placed a 1 there but its really an i because I don't want to be seen as cheating when I do the submissions. But it still does not work. nothing happening Quote Link to comment https://forums.phpfreaks.com/topic/134533-final-year-project-please-point-me-in-the-right-direction/page/4/#findComment-714742 Share on other sites More sharing options...
Mchl Posted December 13, 2008 Share Posted December 13, 2008 Show as your full script Quote Link to comment https://forums.phpfreaks.com/topic/134533-final-year-project-please-point-me-in-the-right-direction/page/4/#findComment-714744 Share on other sites More sharing options...
oriental_express Posted December 13, 2008 Author Share Posted December 13, 2008 Here you are <?php $file = fopen("questions.txt", "r"); while (($data = fgetcsv($file, 1000, ",")) !== FALSE) { $questions[]= $data; } fclose($file); //foreach($questions as $quest) //{ //echo $quest[1]; //} $i = 0; ?> <?php if ($questions[$i][3] == $_POST['answer']){ $i = $i + 1; } elseif ($questions[$i][5] == $_POST['answer']){ $i = $i + 2; } ?> <html> <head></head> <h1>Question: <?php echo $questions[$i][1]; ?></h1> <body> <FORM action="tree.php" method="POST"> <input type="radio" name="answer" value="<?php $questions[$i][3]; ?>"> <?php echo $questions[$i][2]; ?> <br> <input type="radio" name="answer" value="<?php $questions[$i][5]; ?>"> <?php echo $questions[$i][4]; ?> <INPUT TYPE=SUBMIT VALUE="submit"> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/134533-final-year-project-please-point-me-in-the-right-direction/page/4/#findComment-714749 Share on other sites More sharing options...
Mchl Posted December 13, 2008 Share Posted December 13, 2008 You have something lacking in here: <input type="radio" name="answer" value="<?php $questions[$i][3]; ?>"> Quote Link to comment https://forums.phpfreaks.com/topic/134533-final-year-project-please-point-me-in-the-right-direction/page/4/#findComment-714753 Share on other sites More sharing options...
oriental_express Posted December 13, 2008 Author Share Posted December 13, 2008 You have something lacking in here: <input type="radio" name="answer" value="<?php $questions[$i][3]; ?>"> its the echo right ? Woo hoo yesssssssss it works ! I feel ike i can breathe now *does the chicken dance* Quote Link to comment https://forums.phpfreaks.com/topic/134533-final-year-project-please-point-me-in-the-right-direction/page/4/#findComment-714759 Share on other sites More sharing options...
oriental_express Posted December 13, 2008 Author Share Posted December 13, 2008 I think my next step is to go through a few questions and as the user gets near the end the perhaps offer a solution. Do you think its easier to use a solution as text or an html file ? What easier interms of getting something to appear ? BTW will i still be using sessions ? From what it seems , it looks like i wont (correct me if im wrong ?) Quote Link to comment https://forums.phpfreaks.com/topic/134533-final-year-project-please-point-me-in-the-right-direction/page/4/#findComment-714774 Share on other sites More sharing options...
DeanWhitehouse Posted December 13, 2008 Share Posted December 13, 2008 Sessions should be used to track what question they are on so they can't go back Quote Link to comment https://forums.phpfreaks.com/topic/134533-final-year-project-please-point-me-in-the-right-direction/page/4/#findComment-714777 Share on other sites More sharing options...
Mchl Posted December 13, 2008 Share Posted December 13, 2008 And also store the answers (if you want to store them) Why not have a php script, that will load a solution from txt file and display it as HTML Quote Link to comment https://forums.phpfreaks.com/topic/134533-final-year-project-please-point-me-in-the-right-direction/page/4/#findComment-714779 Share on other sites More sharing options...
oriental_express Posted December 13, 2008 Author Share Posted December 13, 2008 Sessions should be used to track what question they are on so they can't go back Hi there, thanks for you reply umm I would like to know why the can't can't go back. I've been testing it and my browser lets me go back to see the previous question ? And also store the answers (if you want to store them) Why not have a php script, that will load a solution from txt file and display it as HTML When you say store answers, that i dont understand, do you mean store clicks they have done ? and if they return to the page it will show the last question they were on ? Is there a way to load a HTML file ? using the text file if i placed in the address www.etc.com ? I just want to know if it's possible so i don't try and do something i cant. No answers please as usaul Quote Link to comment https://forums.phpfreaks.com/topic/134533-final-year-project-please-point-me-in-the-right-direction/page/4/#findComment-714797 Share on other sites More sharing options...
Mchl Posted December 13, 2008 Share Posted December 13, 2008 You mean no direct answers I suppose? If you want the users to be able to go back or not, is up to you. You could use sessions to forbid them. Also, you might use sessions, so that you can save all the answers a user have given to a file, in order to.. I don't know... analyze them later or something. If you don't need that... you probably will not need sessions at all. Yes, you can load a txt file (and HTML is just a txt file) from the url address PROVIDED that your server allows that. You have to check if allow_url_fopen is enabled. There's one more thing missing from your script. You'll see once you have more questions in your file. Quote Link to comment https://forums.phpfreaks.com/topic/134533-final-year-project-please-point-me-in-the-right-direction/page/4/#findComment-714805 Share on other sites More sharing options...
oriental_express Posted December 13, 2008 Author Share Posted December 13, 2008 Yep no direct " Also, you might use sessions, so that you can save all the answers a user have given to a file, in order to.. I don't know... analyze them later or something. If you don't need that... you probably will not need sessions at all. " Good point mate. I think i do want that. To perhaps tailor my expert system There's one more thing missing from your script. You'll see once you have more questions in your file. I have no idea right now but yeah.... am gonna work on it This script is farrrrrrrrr from finished ! I still need to work with " if theres no element echo element 1 ( the html file url ) Something like that Am I going along the right lines ? Thanks again. ! Quote Link to comment https://forums.phpfreaks.com/topic/134533-final-year-project-please-point-me-in-the-right-direction/page/4/#findComment-714818 Share on other sites More sharing options...
Mchl Posted December 13, 2008 Share Posted December 13, 2008 Yeah. Basically you have to recognize, if it is the first question, or later so that you can actually get farther that second question Quote Link to comment https://forums.phpfreaks.com/topic/134533-final-year-project-please-point-me-in-the-right-direction/page/4/#findComment-714823 Share on other sites More sharing options...
oriental_express Posted December 20, 2008 Author Share Posted December 20, 2008 Hello there again. Been so busy with baby etc, loss alot of sleep grrr I've been playing around with the script and your right, how come it doesn't go past the second question ? even though $i is assigned the number 2 and if you select it again why does it not add 2 to it again ? I've tried to work around it by doing something like <?php if ($questions[$i][3] == $_POST['answer']){ // $i = $i + 1; //$questions[$i][3]; $i = $questions[$i][3] == an element in $questions[$i]; // trying to do something like that but I know the value in the element is just a value and not an integer ? does that make sense ? } elseif ($questions[$i][5] == $_POST['answer']){ $i = $i + 2; } ?> I would like some hints to what im doing wrong ? and again no direct answers please Quote Link to comment https://forums.phpfreaks.com/topic/134533-final-year-project-please-point-me-in-the-right-direction/page/4/#findComment-720456 Share on other sites More sharing options...
Mchl Posted December 20, 2008 Share Posted December 20, 2008 Remember that PHP script is running once, and then forgets all about its past. When you select answer for a question, you run another instance of your script, that doesn't remember, what $i was last time it run. Sorry, I'm busy more than usual tonight (is night here) so I might not reply as often as usual Quote Link to comment https://forums.phpfreaks.com/topic/134533-final-year-project-please-point-me-in-the-right-direction/page/4/#findComment-720457 Share on other sites More sharing options...
oriental_express Posted December 22, 2008 Author Share Posted December 22, 2008 hi mchl i'm going to pm you what ive done as i dont want to post my code just yet for google indexing reasons I progressed quite abit i believe Quote Link to comment https://forums.phpfreaks.com/topic/134533-final-year-project-please-point-me-in-the-right-direction/page/4/#findComment-721371 Share on other sites More sharing options...
Mchl Posted December 22, 2008 Share Posted December 22, 2008 Will check it out, when I got a minute (the x-mas season is killing me) Quote Link to comment https://forums.phpfreaks.com/topic/134533-final-year-project-please-point-me-in-the-right-direction/page/4/#findComment-721473 Share on other sites More sharing options...
oriental_express Posted December 22, 2008 Author Share Posted December 22, 2008 Will check it out, when I got a minute (the x-mas season is killing me) No worries mate, your work comes first ! Thanks again for support ! Have a good christmas ! Quote Link to comment https://forums.phpfreaks.com/topic/134533-final-year-project-please-point-me-in-the-right-direction/page/4/#findComment-721490 Share on other sites More sharing options...
oriental_express Posted December 28, 2008 Author Share Posted December 28, 2008 Hello everyone, i think i've cracked it for now The script is able to go to any questions that is in the CSV file or text file http://minhtri-nguyen.com/tree.php http://minhtri-nguyen.com/questions.csv I've also uploaded the CSV file to you can see what is going on The CSV is a load of nonsense because I just wanted to test. Script needs to be improved so watch this space......... Comment are appreciated Quote Link to comment https://forums.phpfreaks.com/topic/134533-final-year-project-please-point-me-in-the-right-direction/page/4/#findComment-724969 Share on other sites More sharing options...
Mchl Posted December 28, 2008 Share Posted December 28, 2008 Nice to hear you're doing progress! Can't open links you're provided though... Quote Link to comment https://forums.phpfreaks.com/topic/134533-final-year-project-please-point-me-in-the-right-direction/page/4/#findComment-724972 Share on other sites More sharing options...
oriental_express Posted December 28, 2008 Author Share Posted December 28, 2008 http://minhtri-nguyen.com/tree.php this not working ? fine on my end, can anyone else confirm please ? Quote Link to comment https://forums.phpfreaks.com/topic/134533-final-year-project-please-point-me-in-the-right-direction/page/4/#findComment-724973 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.