0 )
{
# grab info
$query = "select id, catid, company_name, contact_name, address, city, state, zipcode, phone, email, url from vendors where id=". $editid;
$rsVendor = mysql_query($query);
if( !$rsVendor || @mysql_num_rows($rsVendor) < 1 )
die('That ID does not exist');
$query = "select catid, name from category order by name asc";
$rsCategory = mysql_query($query);
$vendor = mysql_fetch_array($rsVendor, MYSQL_ASSOC);
?>
Vendor Details
Add Vendor
0 ) {
## id to edit is $editid, declared in condition above
// check for errors
$err = false; // currently, there is no errors.
$errmsg = 'Error ';
// empty error msg. msg with no current errors.
// check to see if content field is empty or not. if so, make error.
if( empty($_POST['contact_name']) )
{
$err = true; // there is now an error.
$errmsg .= 'Content is a required field and must be filled out. '; // append an error msg to the end of $errmsg
}
if($err) die($errmsg); // if there's an error ( $err = true ), let them know and exit.
if(!$err) // if no errors, do the foloowing
{
// store the fields into an easier writeable variable. so you dont have to type $_POST[''] to use it everytime.
$contact_name = $_POST['contact_name'];
$company_name = $_POST['business_name'];
//connect to the mysql server
//insert the new info into the database
$query = "update contact set contact_name='". $contact_name ."',
business_name='". $business_name ."' where id = '".mysql_real_escape_string($editid)."'";
$result = mysql_query($query) or die(mysql_error());
echo ' return ';
}
}
?>