Jump to content

Recommended Posts

Hello I created a form where the table to enter into uses calls from a database for the questions, but the generated fields are not called they are created with a foreach. The form calls just fine, however when I go to the page to process and update the table, it does not seem to want to insert the answers on an update. I have tried variable combinations and tried to research the problem to no avail. HELP!!!

 

form coding


$result = mysql_query("SELECT * FROM interviews WHERE id='$int'");
while($row = mysql_fetch_array($result)){ $a = $row[1]; $b = $row[2]; $c = $row[3]; $d = $row[4]; $e = $row[5]; $f = $row[7]; $g = $row[8]; $h = $row[9]; }

$i = array();
$result = mysql_query("SELECT * FROM dbinter WHERE interview_id='$int'");
while($row = mysql_fetch_array($result)){ $i[] = $row[2]; }

$l = array();
$result = mysql_query("SELECT * FROM form_custom WHERE attached='$cid' && date='$e'");
while($row = mysql_fetch_array($result)){ $l[] = $row[0]; }

echo "<font style='font-size: 45px;'>$a $b</font>";

echo "<p><font style='font-size: 20px;'>$c
<br />$d</font></p>";

echo "<form method='POST' name='interview' action='interviewsheet.php?cid=$cid&int=$int&stat=proc'>";
echo "<div style='margin-top:50px;'><input type='submit' value='COMPLETE INTERVIEW'></div>";

foreach($i as $j){
$result = mysql_query("SELECT * FROM form WHERE id='$j'");
while($row = mysql_fetch_array($result)){ $k = $row[2]; }
echo "
<div style='margin: 20px;'>
<font styler='font-size: large; font-weight: bold;'>$k</font><br />
<textarea rows='5' cols='60' style='border: none;' name='q'></textarea>
</div>
";}

foreach($l as $m){
$result = mysql_query("SELECT * FROM form_custom WHERE id='$m'");
while($row = mysql_fetch_array($result)){ $n = $row[2]; }
echo "
<div style='margin: 20px;'>
<font styler='font-size: large; font-weight: bold;'>$n</font><br />
<textarea rows='5' cols='60' style='border: none;' name='qc'></textarea>
</div>
";}
echo "</div>";

 

Here is the processing page code:

 


$act = $_GET['act'];
$cid = $_GET['cid'];
$int = $_GET['int'];
$stat = $_GET['stat'];
$sub = $_GET['sub'];

if($stat == "proc"){

$c = array();
$c[] = $_POST['q'];
foreach($c as $b => $d){
$sql = "UPDATE dbinter SET answer='$d' WHERE interview_id='$int'";
if (!mysql_query($sql,$con)){die('Error: ' . mysql_error());}
}

$f = array();
$f[] = $_POST['q'];
foreach($f as $g => $f){
$sql = "UPDATE dbinter SET answer='$f' WHERE attached='$cid'";
if (!mysql_query($sql,$con)){die('Error: ' . mysql_error());}
}

Edited by JLitkie
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.