View Full Version : edit section of interview script

06-08-2004, 08:44 PM
Hi again,
I have managed to make a suitable way of adding a interview which can be found Here (http://www.tdwork.com/test/log/admininter/editinter.php?action=) but as you can see the edit section is where i am needing help with.
I simply want it to ouput what is currently in the databse but cant seem to output them into each line of the corosponding Questions and answers. Then be able to delete or add lines where needed

I have kept the amount of Q's and A's in a table called qna if that helps at all

Here is the edit page
you can just foccus on the part after

require '../db_connect.php';
include 'adminmenu.php';
include 'sub.php';
echo'<div align="center"><br>';

if ($_GET['action'] == '') {
$sql = "SELECT *
FROM interview ORDER BY id DESC";

$res = $db_object->query($sql);

if (DB::isError($res)) {

while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {

echo'<strong><li>Interview With '.$row->interviewie.'</li></strong><br>
Added by '.$row->interviewer.' on '.$row->dop.'<br>
<a href="?action=edit&id='.$row->id.'">Edit Interview</a><br>
<a href="?action=delete&id='.$row->id.'">Delete Interview</a><br><br>';


if ($_GET['action'] == 'edit') {

$sql = "SELECT *
FROM interview WHERE id = '".$_GET['id']."'";

$res = $db_object->query($sql);

if (DB::isError($res)) {

while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
$questions = $row->questions;
$answers = $row->answers;
$numlines = $row->qna;

$qna = array();
// Build an Array of the questions and answers

while($_POST['question'.$x]) {
if ($_POST[$x] != 'Delete') {
for($y=0;$y<=$numlines-1;$y++) {
$question = explode("|SEPARATOR|" , $questions);
$question[$y] = $question[$y];

$answer = explode("|SEPARATOR|" , $answers);
$answer[$y] = $answer[$y]; }

$qna[$w]['question'] = $question[$y];
$qna[$w]['answer'] = $answer[$y];

echo'<strong><li>Interview With '.$row->interviewie.'</li></strong><br>
Added by '.$row->interviewer.' on '.$row->dop.'<br>

<FORM METHOD="post" ACTION="'.$PHP_SELF.'?action=edit"><TABLE width="518" height="211" border="0" align="center" cellpadding="0" cellspacing="0">
<TR><TD width="234"> name of interviewer
<INPUT TYPE="text" NAME="interviewer" value="'.$row->interviewer.'"></TD>
<TD width="234">name of interviewie
<input type="text" name="interviewie" value="'.$row->interviewie.'"></TD>
<TD width="50">&nbsp;</TD>
<TR><TD height="109"><p> Question
<textarea name="question'.$y.'" cols="40" wrap="VIRTUAL"></textarea>
<textarea name="answer'.$y.'" cols="40" wrap="VIRTUAL"></textarea></TD>

<TR><TD><INPUT TYPE="submit" NAME="addline" class="button" VALUE="Add Line to Interview"><br><br></TD></TR>
for($y=0;$y<=$numlines;$y++) {

echo '<TR><TD> <p>Question #'.$y.'
<textarea name="question'.$y.'" cols="40" wrap="VIRTUAL">'.$qna[$y]['question'].'</textarea>
<TD>Answser to Question #'.$y.'
<textarea name="answer'.$y.'" cols="40" wrap="VIRTUAL">'.$qna[$y]['answer'].'</textarea></TD>
<TD> <p><input type="submit" name="'.$y.'" class="button" value="Delete"> </p>
'; }
if ($y == '1' ) {echo '';} else{ echo' <TR><TD><br><br><INPUT TYPE="submit" class="button" NAME="submit" VALUE="Edit Interview"></TD></TR>';} echo'

echo' <br><br><a href="?action=">BACK</a><br>';