Jump to content

Final year project, please point me in the right direction


oriental_express

Recommended Posts

  • Replies 115
  • Created
  • Last Reply

Top Posters In This Topic

Working now. Don't know why it didn't the first time.

 

Thats great, so yeah.....it works. Now thats been done I've practically finished 80% of the project (software wise) and only completed 20% of written work.

I just gotta touch up on extra stuff like formating the html, thinking of a good way to display an answer

either to produce a new page or just simply echo the answers underneath..not sure if thats gonna be neat with the radio buttons etc.

 

Now I just got to do my project write up. Massive weight of my shoulders now. I've been thinking of the sessions.......this I would like to implement as collecting information would be useful to a non programmer that might use this script for their own exper system. I'll be around to update :)

Link to comment
Share on other sites

  • 3 weeks later...

Hi there everyone. I finished my exams and now concentrating on this project ready for hand in on 1st May. I been thinking that I would like to display the previous question but I have a feeling that I will need some ajax component, this will be slightly more difficult.

Is there any other easier way to do this considering the time I have left ? I can't see it happening without the use of ajax. Could anyone confirm please.

 

http://minhtri-nguyen.com/tree.php

http://minhtri-nguyen.com/questions.csv

Link to comment
Share on other sites

It is entirely possible to display previous question (and answer to it) without AJAX.

 

Thats greate !!

This is what I'd live to accomplish

This is an example on the NHS website

http://www.selfhelpguide.nhs.uk/help/bodykey/questions/index.aspx?nodes=FlgWPcj%2f1Ow%3d

 

Is it possible to dispall ALL previous questions and answers to it ?

Where should I start looking ?

 

Thank you

 

Link to comment
Share on other sites

This is what I'd live to accomplish

This is an example on the NHS website

http://www.selfhelpguide.nhs.uk/help/bodykey/questions/index.aspx?nodes=FlgWPcj%2f1Ow%3d

 

Oh my! It's asking me about my vagina!

 

lol try it on other body parts.

Its an exellent example cause your even able to

correct previous questions and then go down

a different tree path.

 

Where should i be looking to just display all previous

questions ?

Link to comment
Share on other sites

Each time you display a question, you should store it in session. Once you get the answer for that, it should also go into a session.

When you display second or later question, you also display all questions and their answers stored in session. Walk in the park (after dark).

Link to comment
Share on other sites

Each time you display a question, you should store it in session. Once you get the answer for that, it should also go into a session.

When you display second or later question, you also display all questions and their answers stored in session. Walk in the park (after dark).

 

thank you mchl, let me see what i can cough up. Might be a while :P

thanks again !

Link to comment
Share on other sites

  • 2 weeks later...

Hi there again I'm back :D I hope everyone is ok! Ok I last said that I wanted to use sessions to track answers but I think I want to put that on the back burner for a minuite as I think I need to implement something more important. Remember we talked about editing a CSV file and then just up load it ? Trouble is that it requires ftp log in which is kinda of a hassle. With suggestion from my tutor I am now going to use a web interface that will be able to add delete edit values. For now I am stuck.

 

File form.php

<?php $file = fopen("questions.csv", "r"); 
while ($data = fgetcsv($file, 1000))  
{
   $questions[]= $data;
}
fclose($file);
?>


<form action="save.php" method="post">
  <p><br>
    Line no.
  <input type="text" value="<?php echo $questions[0][1]; ?>" size="15" name="save" />  
  <p>
    Questions
    <input type="text" value="<?php echo $questions[0][2]; ?>" size="15" name="save" />
  <p>
  Answer 1
  <input type="text" value="<?php echo $questions[0][3]; ?>" size="15" name="save" />
  </p>
  <p>Answer 1 Line no.
    <input type="text" value="<?php echo $questions[0][4]; ?>" size="15" name="save" />
  </p>
  <p>Answer 2
    <input type="text" value="<?php echo $questions[0][5]; ?>" size="15" name="save" />
</p>
  <p>Answer 2 Line no.
    <input type="text" value="<?php echo $questions[0][6]; ?>" size="15" name="save" />
  </p>
  <p>
    <input name="SUBMIT" type="SUBMIT" value="Edit File" />
    <input name="RESET" type="RESET" />
    
  </p>
  </p>
</FORM>

 

The above echos a form of the data values in textfield from a csv file. When a user edits the file all s/he does is clicks edit which should re edit the csv file.

 

File save.php for now I have

<?php
$file = fopen("questions.csv", "w"); 
while ($data = fgetcsv($file, 1000))  
{
   $questions[]= $data;
}

fwrite($file, $_POST['save']);
fclose($file);
header('Location: http://127.0.0.1/Tree/phptextedit/form.php');
?>

 

I know that is incorrect because it wipes out the whole csv file and replaces it with only one of the edit values from the form. ie its not editing properly. What is confusing me is when we do "$questions[]= $data;" this is all loaded into memory but how would do it so that a file knows whats whats ? How does a fa CSV file know [ 0][1] is ?

 

I was thinking of doing something along the lines of

 

if ($questions[0][1] == $_GET['save']) && ***** [0][1] of CSV file ***** {
fwrite($file, $_GET['save']);

 

***** [ 0][1] of CSV file *****  thats where I have a problem ?

First of all can such a thing be done ?

Is this the right step ?

I appreciate if someone could guide me as Im not interested in direct answers.

 

Thank you again.

Link to comment
Share on other sites

Sorry, don't really have time to anlyze your code right now. I would however try a different approach.

 

1. Create a HTML form with textarea and submit button.

2. Use file_get_contents to load whole CSV into php variable and display it in HTML textarea

3. Edit the contents of textarea :P

4. After clicking 'Submit' save whole content of textarea to CSV file.

 

This would be the simplest approach IMHO, but would not be foolproof. (i.e. when someone forgets to put a comma between fields, ot does some other error, the resulting CSV file will be corrupt - but repairable :P )

Link to comment
Share on other sites

Sorry, don't really have time to anlyze your code right now. I would however try a different approach.

 

1. Create a HTML form with textarea and submit button.

2. Use file_get_contents to load whole CSV into php variable and display it in HTML textarea

3. Edit the contents of textarea :P

4. After clicking 'Submit' save whole content of textarea to CSV file.

 

This would be the simplest approach IMHO, but would not be foolproof. (i.e. when someone forgets to put a comma between fields, ot does some other error, the resulting CSV file will be corrupt - but repairable :P )

 

Thank you for your reply but my problem with that approach is that it kinda distorts the way it looks

in the textarea, one line might have more text then the other and it condenses and makes it hard to work out with column belongs to which. Is there such thing as making columns in a textarea ?

 

thank you

Link to comment
Share on other sites

  • 8 months later...

Hello everyone

 

I finished my project in May and I graduated with a 1st class Degree in BSc Computing. Woohoo

Now I'm back for my MSc.

 

Thank you to everyone who contributed especially MCHL!

 

I remember reading that someone wanted a tutorial to be made out of this on how to use CSV files to display information in an expert system manner.

 

Here it is working  http://www.phpexpertsystem.com/computer/

 

I couldn't figure out how to "end" the decision tree properly.

 

MCHL Let me know if you have to time to do this as I'm swamped for work  :'( or I could just post up the code?

 

Best regards

Michael

 

PS thank you very much! Much appreciated!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • 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.