Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    Regular Coder
    Join Date
    Aug 2003
    Location
    scotland, edinburgh
    Posts
    176
    Thanks
    5
    Thanked 1 Time in 1 Post

    thoughts on interview script

    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 [q]question to person[/q] and that puts the interviews name beside that paragraph and makes it bold
    3. when he adds the answer he puts in [a]question to person[/a] 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

  • #2
    Regular Coder
    Join Date
    Sep 2002
    Location
    Scotland
    Posts
    407
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    My body's a temple... and like those ancient Greek ones it's a ruin
    sweenster.co.uk

  • #3
    Regular Coder
    Join Date
    Aug 2003
    Location
    scotland, edinburgh
    Posts
    176
    Thanks
    5
    Thanked 1 Time in 1 Post
    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

  • #4
    Regular Coder
    Join Date
    Sep 2002
    Location
    Scotland
    Posts
    407
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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".
    My body's a temple... and like those ancient Greek ones it's a ruin
    sweenster.co.uk

  • #5
    New Coder
    Join Date
    May 2004
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

    PHP Code:
    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!
    "The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect."

    --Tim Berners-Lee, W3C Director and Inventor of the World Wide Web

  • #6
    Regular Coder
    Join Date
    Aug 2003
    Location
    scotland, edinburgh
    Posts
    176
    Thanks
    5
    Thanked 1 Time in 1 Post
    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

  • #7
    New Coder
    Join Date
    May 2004
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here we go... working script.. ill leave you to write the "submit" side of things but if you need help just yell!
    PHP Code:
    <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.
    "The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect."

    --Tim Berners-Lee, W3C Director and Inventor of the World Wide Web

  • #8
    Regular Coder
    Join Date
    Aug 2003
    Location
    scotland, edinburgh
    Posts
    176
    Thanks
    5
    Thanked 1 Time in 1 Post
    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
    Last edited by tsclan; 06-04-2004 at 02:56 PM.

  • #9
    Regular Coder
    Join Date
    Aug 2003
    Location
    scotland, edinburgh
    Posts
    176
    Thanks
    5
    Thanked 1 Time in 1 Post
    should i repost this to get more attention as this is no longer about getting new ideas its about help with a script
    Last edited by tsclan; 06-04-2004 at 04:59 PM.

  • #10
    Regular Coder
    Join Date
    Jun 2003
    Location
    Australia
    Posts
    528
    Thanks
    8
    Thanked 8 Times in 8 Posts
    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!

    Taylor.

  • #11
    Regular Coder
    Join Date
    Jun 2002
    Location
    Sheffield, UK
    Posts
    552
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    "To be successful in IT you don't need to know everything - just where to find it in under 30 seconds"

    (Me Me Me Me Me Me Me Me Me)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •