Forum Moderators: coopster
if ($submit) {
mysql_query ("INSERT INTO profile_edu (cid,Education,School,Program) VALUES ('$uid','$Education','$School','$Program')");
?>
<form method="post" action="<?php echo $PHP_SELF?>">
<table>
<tr>
<td><font size="-2">Education</font><br>
<input type="Text" name="Education"></td>
<td><font size="-2">School</font><br>
<input type="Text" name="School"></td>
<td><font size="-2">Program</font><br>
<input type="Text" name="Program"></td>
</tr>
<tr>
<td colspan="3"><div align="right">
<input type="reset" value="Reset">
<input type="Submit" name="submit" value="Add">
</div></td>
</tr>
</table>
</form>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<?php
}
// read data from database
$p_edu = mysql_query("SELECT * FROM profile_edu") // WHERE cid = '$uid'
or die ("Could not read data because ".mysql_error());
// print the data in a table
if (mysql_num_rows($p_edu)) {
print "<table cellpadding=2 cellspacing=0 border=0 width=\"100%\">\n";
print "<tr><th>Education</th><th>School</th><th>Program</th></tr>\n";
while ($qry = mysql_fetch_array($p_edu)) {
print "<tr><td>$qry[Education]</td><td>$qry[School]</td><td>$qry[Program]</td></tr>\n";
}
print "</table>\n";
}
if ($submit) {
mysql_query ("INSERT INTO profile_edu (cid,Education,School,Program) VALUES ('$uid','$Education','$School','$Program')");
} <-- move to here
?>
and remove the closing bracket from this section:
</form>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<?php
} Moved up as indicated