JLitkie Posted January 31, 2013 Share Posted January 31, 2013 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());} } Link to comment https://forums.phpfreaks.com/topic/273870-creating-a-dynamic-form-and-updateing-mysql/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.