Jump to content

Archived

This topic is now archived and is closed to further replies.

oriental_express

Final year project, please point me in the right direction

Recommended Posts

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

Share this post


Link to post
Share on other sites

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 :)

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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

 

Share this post


Link to post
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 ?

Share this post


Link to post
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).

Share this post


Link to post
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 !

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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 )

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

Congratulations! I would very much like to see the code if you don't mind uploading it somewhere (can you attach files here in forums?)

Share this post


Link to post
Share on other sites

×

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.