...

View Full Version : thoughts on interview script



tsclan
06-03-2004, 04:59 AM
all I really need help with is ideas of how I am going to implement an interview script
I need to make an admin area where admins can post what they said and what he said in return. Then post it onto a public php page
What I need help on is the admin section when the admin posts the interview what does he do? thoughts so far:
1. he adds interviewers name and interviewies's name in an input area
2. when he adds a question he puts in question to person and that puts the interviews name beside that paragraph and makes it bold
3. when he adds the answer he puts in question to person and that puts the person thats beining interviewed name beside that paragraph and does not make it bold

so the final product is this

question from Me
how are u

Answer from Him
STFUNOOB

Question from Me
Ok.

as you can see I can think up a few problems that I will encounter when coding this and was wondering if you had any better ideas on how to do this and if possible post snippetts of php when it gets complicated
thanks

sweenster
06-03-2004, 02:30 PM
why not just use individual form fields - one for the question and one for the answer?
these can then be stored seperately in an database and then recombined by the public PHP script in the desired format.

tsclan
06-03-2004, 03:00 PM
then the problem with that is how many Q and A input fields should I make as an interveiw can have 10 questions to 100 questions

sweenster
06-03-2004, 04:12 PM
How long is a piece of string...

Just assign a unique id number for each interview, then have 3 columns in your SQL table:

interview_id
question
answer

Assigning a unique id number for each interview means all the related questions should have the same interview_id number - then you can do a simple SQL query - "SELECT * FROM data WHERE interview_id=104" to pull up all the questions from interview number 104.

Then when the interviewer is updating the question instead of just a submit button have two - "submit question and add another" and "submit question and end".

LynxGrr
06-03-2004, 05:17 PM
Heres a piece of code that will collect the info from the previous form, display it, and then provide new text inputs for the next questions. Its untested as I've just pulled it from one of my own scripts.


if ($_POST['addline']) {
$qna = array();
$x=1;
// Build an Array of the questions and answers
while($_POST['question'.$x]) {
$qna[$x]['question'] = $_POST['question'.$x];
$qna[$x]['answer'] = $_POST['answer'.$x];
$x++;
}
// Display previous questions and answers, and two new text inputs
echo "<TABLE>\n";
for($y=1;$y<=count($qna);$y++) {
echo "<TR><TD>".$qna[$y]['question']."</TD><TD>".$qna[$y]['answer']."</TD></TR>";
}
echo "<TR><TD><INPUT TYPE=\"text\" NAME=\"question$y\"></TD><TD><INPUT TYPE=\"text\" NAME=\"answer$y\"></TD></TR>\n";
echo "</TABLE>\n";
}


Hope its useful!

tsclan
06-03-2004, 08:56 PM
thats a good idea and possible the thing that i need so if it would be great i can get some help on that code to get it working to its basic level

LynxGrr
06-03-2004, 11:15 PM
Here we go... working script.. ill leave you to write the "submit" side of things but if you need help just yell!


<HTML>
<HEAD><TITLE>Questions And Answers</TITLE></HEAD>
<BODY>
<?php

if ($_POST['addline']) {
$qna = array();
$x=1;
// Build an Array of the questions and answers
while($_POST['question'.$x]) {
$qna[$x]['question'] = $_POST['question'.$x];
$qna[$x]['answer'] = $_POST['answer'.$x];
$x++;
}
// Display previous questions and answers, and two new text inputs
echo "<FORM METHOD=\"post\" ACTION=\"$PHP_SELF\"><TABLE>\n";
for($y=1;$y<=count($qna);$y++) {
echo "<TR><TD><INPUT TYPE=\"text\" NAME=\"question$y\" VALUE=\"".$qna[$y]['question']."\"></TD>\n";
echo "<TD><INPUT TYPE=\"text\" NAME=\"answer$y\" VALUE=\"".$qna[$y]['answer']."\"></TD></TR>";
}
echo "<TR><TD><INPUT TYPE=\"text\" NAME=\"question$y\"></TD><TD><INPUT TYPE=\"text\" NAME=\"answer$y\"></TD></TR>\n";
echo "<TR><TD><INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Submit\"></TD><TD>\n";
echo "<INPUT TYPE=\"submit\" NAME=\"addline\" VALUE=\"Add Line\"></TD></TR>\n";
echo "</TABLE></FORM>\n";


} else {


echo "<FORM METHOD=\"post\" ACTION=\"$PHP_SELF\"><TABLE>\n";
echo "<TR><TD><INPUT TYPE=\"text\" NAME=\"question1\"></TD><TD><INPUT TYPE=\"text\" NAME=\"answer1\"></TD></TR>\n";
echo "<TR><TD><INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Submit\"></TD><TD>\n";
echo "<INPUT TYPE=\"submit\" NAME=\"addline\" VALUE=\"Add Line\"></TD></TR>\n";
echo "</TABLE></FORM>\n";

}

?>

</BODY>
</HTML>


Questions on the left and answers on the right... and the previously entered questions go into text inputs in case they need editing afterwards.

tsclan
06-04-2004, 02:25 AM
yellllllllllllllllllllllllllllllllllllllllllllllllllow
I thank you a lot and I am very greatful foru your help and the script works wonders but I was wondering if you could help again, I was wondering if there could be a delete fuction included in this script. Where if they want to delete line 3 out of 5 they can. If thats not too much trouble
thank you

tsclan
06-04-2004, 05:57 PM
should i repost this to get more attention as this is no longer about getting new ideas its about help with a script

Taylor_1978
06-04-2004, 06:03 PM
I'm all for the purpose of these fourms of getting help... HOWEVER; unless I am mistaken - it sounds like you are actually trying to get someone to write the script for you!

You should really try writing the script yourself and reading up on manuals in www.php.net and then when a script will not work, post it here and you will get quicker responses so that people can identify your mistake and help fix it - rather than writing the whole thing themselves.

I have learnt leaps and bounds from these forums by posting my silly mistakes and others gladly helping and showing me easier ways to do things... but I would not have a clue if it wasn't for my own trial and error and research also.

Good Luck! :D

Taylor.

ReadMe.txt
06-05-2004, 03:05 AM
i reckon you'd be better off using javascript to keep extending the form instead of passing via php each time, that way you only need to submit once.

Just have each pair of textareas have an array key and then you can assemble them all with and assign them a ranking order for pulling out of the DB.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum