Forum Moderators: coopster
I'm trying to populate a drop down list from a table. I'm stuck with the following error;
Parse error: parse error, unexpected '<' in d:\program files\easyphp1-7\www\droptrial.php on line 63.
Can some kind expert help me on my way? Here is my rickety code (I have marked line 63 with '//------this is line 63 folks') & thank you for your help;
<HTML>
<BODY>
<h2>Add new DirDeb record</h2>
<STYLE>
.error {padding: 10px; color: #cc0000; font-weight: bold;}
</STYLE>
<?
if ($_POST) {
$msg = "";
foreach($_POST as $k => $v) {
$v = trim($v) ;
$$k = $v ;
if ($v=="") {
$msg = "please fill in all fields";
}
}
// if all data is there, build the query
if ($msg=="") {
$insert = "INSERT INTO creditor_amount
(amount, name, dd_date)
VALUES ('$amo', '$nam', '$dat')";
include 'config.php';
include 'opendb.php';
echo 'Connected successfully';
$link = mysql_connect('localhost','root','mypassword');
mysql_select_db('mydatabase');
//execute the query and check for success
if (!mysql_query($insert, $link)) {
$msg = "Error inserting data";
} else {
$msg = "Record successfully added";
// set vars to "" for next form input
$amo = $nam = $dat = "";
}
include 'closedb.php';
}
//print error or success messages
echo "<div class=\"error\">$msg</div>";
// if not submitted, create blank vars for form inputs
} else {
$amo = $nam = $dat = "";
}
?>
<FORM METHOD="post" ACTION="<? echo
$_SERVER['PHP_SELF'] ?>" />
<!--set up the table-->
<TABLE BORDER="1" CELLPADDING="5">
<TR>
<TH>amount</TH>
<TH>name</TH>
<TH>date</TH>
</TR>
<TR>
<TD><INPUT TYPE="text" NAME="amo" VALUE="<?
echo $amo ?>" /></TD>
<TD><SELECT NAME="nam" Value="<? $query="SELECT id, name FROM creditor_amount ORDER BY name ASC";
$result = mysql_query ($query);
echo "<select name=id value=''>name</option>";
while($nt=mysql_fetch_array($result)){
echo "<option value=$nt[id]>$nt[name]</option>";
}
echo "</select>" ;
</TD> //---------------------------this is line 63 folks
?>
<TD><INPUT TYPE="text" NAME="dat" VALUE="<?
echo $dat ?>" /></TD>
</TR>
</TABLE>
<INPUT TYPE="submit" VALUE="Add to database" />
<INPUT TYPE="reset" VALUE="Cancel" />
</FORM>
</BODY>
</HTML>