- Mar 25, 2001
- 5,287
- 6
- 81
Here is the deal, I want to be able to update the record through the form. So I want to populate the form first with the original data. Then the user sees the original content, modifies the entry in the form, and hits the update button, which in turn sends the update query to MySQL server....
Here is how it works...
$sql = mysql_query ("SELECT InvoiceNumber, FName, LName, Address, City, State, Zip, Tel, Email,
FROM customerdata,
WHERE InvoiceNumber LIKE '$snumber'");
$row = mysql_fetch_array($sql);
print "<form action=\"updatequery.php\" method=\"post\">";
do
{
print "<p>";
print "<font face=\"Century Gothic\" size=\"2\">Service Order#: </font>";
print "<input type=\"text\" name=\"service\" size=8 value=";
print $row['InvoiceNumber'];
print ">";
print "<font face=\"Century Gothic\" size=\"2\"> First name: </font>";
print "<input type=\"text\" name=\"fname\" size=15 value=";
print $row['FName'];
print ">";
print "<font face=\"Century Gothic\" size=\"2\"> Last name: </font>";
print "<input type=\"text\" name=\"lname\" size=15 value=";
print $row['LName'];
print "><br />";
print "<p>";
print "<font face=\"Century Gothic\" size=\"2\">Address: </font>";
print "<input type=\"text\" name=\"address\" size=14 value=";
print $row['Address'];
print " >";
print "<font face=\"Century Gothic\" size=\"2\"> City: </font>";
print "<input type=\"text\" name=\"city\" size=11 value=";
print $row["City"];
print ">";
print "<font face=\"Century Gothic\" size=\"2\"> State: </font>";
print "<input type=\"text\" name=\"state\" size=2 value=";
print $row["State"];
print ">";
print "<font face=\"Century Gothic\" size=\"2\"> Zip: </font>";
print "<input type=\"text\" name=\"zip\" size=4 value=";
print $row["Zip"];
print ">";
print "<font face=\"Century Gothic\" size=\"2\"> Tel#: </font>";
print "<input type=\"text\" name=\"tel\" size=9 value=";
print $row["Tel"];
print "><br />";
print "<p>";
print "<font face=\"Century Gothic\" size=\"2\">E-mail: </font>";
print "<input type=\"text\" name=\"email\" size=17 value=";
print print $row["Email"];
print ">";
print " <input type=\"submit\" value=\"Update Record\" /></form>";
} while ($row = mysql_fetch_array($sql));
OK, let me state that this code works, but not in 100%. The fields address and city are populated only partially.
Ie if the field "adress" has a value of "12345 Trigger St", only "12345" will show up in the form. This same applies to the field "city". The name of the city is "Ann Arbor", but only "Ann" will pop up in the form...?
Help,
What I am doing wrong?
The records in the database are setup to use varchar type. Maybe that is the problem?
Here is how it works...
$sql = mysql_query ("SELECT InvoiceNumber, FName, LName, Address, City, State, Zip, Tel, Email,
FROM customerdata,
WHERE InvoiceNumber LIKE '$snumber'");
$row = mysql_fetch_array($sql);
print "<form action=\"updatequery.php\" method=\"post\">";
do
{
print "<p>";
print "<font face=\"Century Gothic\" size=\"2\">Service Order#: </font>";
print "<input type=\"text\" name=\"service\" size=8 value=";
print $row['InvoiceNumber'];
print ">";
print "<font face=\"Century Gothic\" size=\"2\"> First name: </font>";
print "<input type=\"text\" name=\"fname\" size=15 value=";
print $row['FName'];
print ">";
print "<font face=\"Century Gothic\" size=\"2\"> Last name: </font>";
print "<input type=\"text\" name=\"lname\" size=15 value=";
print $row['LName'];
print "><br />";
print "<p>";
print "<font face=\"Century Gothic\" size=\"2\">Address: </font>";
print "<input type=\"text\" name=\"address\" size=14 value=";
print $row['Address'];
print " >";
print "<font face=\"Century Gothic\" size=\"2\"> City: </font>";
print "<input type=\"text\" name=\"city\" size=11 value=";
print $row["City"];
print ">";
print "<font face=\"Century Gothic\" size=\"2\"> State: </font>";
print "<input type=\"text\" name=\"state\" size=2 value=";
print $row["State"];
print ">";
print "<font face=\"Century Gothic\" size=\"2\"> Zip: </font>";
print "<input type=\"text\" name=\"zip\" size=4 value=";
print $row["Zip"];
print ">";
print "<font face=\"Century Gothic\" size=\"2\"> Tel#: </font>";
print "<input type=\"text\" name=\"tel\" size=9 value=";
print $row["Tel"];
print "><br />";
print "<p>";
print "<font face=\"Century Gothic\" size=\"2\">E-mail: </font>";
print "<input type=\"text\" name=\"email\" size=17 value=";
print print $row["Email"];
print ">";
print " <input type=\"submit\" value=\"Update Record\" /></form>";
} while ($row = mysql_fetch_array($sql));
OK, let me state that this code works, but not in 100%. The fields address and city are populated only partially.
Ie if the field "adress" has a value of "12345 Trigger St", only "12345" will show up in the form. This same applies to the field "city". The name of the city is "Ann Arbor", but only "Ann" will pop up in the form...?
Help,
What I am doing wrong?
The records in the database are setup to use varchar type. Maybe that is the problem?
