Welcome To The Contact Database
"; echo "You have the following choices:"; echo "
"; echo " List Organizations in the database.

"; echo "Search for a service provider by keyword.

"; echo "Enter a new service organization.

"; echo "Edit an existing record.

"; echo ""; echo "

"; } /* The records appear in a table */ Function Show_Table (){ global $hostname, $password, $user; echo "

Service Organizations

"; echo "

Click on the service organization to see the more details.

"; mysql_connect("$hostname", "$user", "$password"); $result = mysql("services","SELECT * FROM organization"); echo ""; $total_rows = mysql_numrows($result); $counter = 0; echo ""; while($counter < $total_rows) { $uid = mysql_result($result,$counter,uid); echo "\n"; echo "\n"; echo "\n"; $counter = $counter + 1; } echo "
UIDService OrganizationPhone Number
\n"; echo mysql_result($result,$counter,uid); echo ""; echo mysql_result($result,$counter,org); echo "\n"; echo "\n"; echo mysql_result($result,$counter, phone); echo "
"; } Function Empty_Form (){ global $state, $org, $email, $phone, $fax, $address1, $address2, $URL, $uid, $first_name, $last_name; echo "

General Service Organization Information

\n"; echo "

\n"; echo " \n"; echo " \n"; echo " Service Organization:

\n"; echo " Phone:

\n"; echo " Fax:

\n"; echo " Campus Address:

\n"; echo " URL:

\n"; echo "

Specific Service and Direct Contact Information

\n"; echo " Describe your services or keywords that your clients might use to refer to your services.

\n"; echo " First Name:

\n"; echo " Last Name:

\n"; echo " Email:

\n"; echo "

\n"; echo "
\n"; } Function Insert_Record () { global $state, $org, $email, $phone, $fax, $address1, $address2, $service, $URL, $uid, $first_name, $last_name; mysql_connect("luna","maggot","fzr400dead"); $result = mysql("services","SELECT now()"); $now = mysql_result($result,0,"now()"); $result = mysql("services","INSERT INTO organization (org, phone, fax, email, address_1, address_2, URL) VALUES ('$org', '$phone', '$fax', '$email', '$address1', '$address2', '$URL')"); $new_uid = mysql_insert_id(); $uid = $new_uid; $result = mysql("services","INSERT INTO service (uid, entry_date, service) VALUES ('$new_uid', '$now', '$service')"); $result = mysql("services","INSERT INTO contacts (uid, first_name, last_name) VALUES ('$new_uid', '$first_name', '$last_name')"); Show_Full_Record($uid); } Function Show_Full_Record (){ global $state, $name, $org, $email, $phone, $fax, $address1, $address2, $service, $URL, $uid, $first_name, $last_name; mysql_connect("luna","maggot","fzr400dead"); $result = mysql("services","SELECT * FROM contacts WHERE uid=$uid"); $name = mysql_result($result,0,first_name); $name = $name . " " . mysql_result($result,0,last_name); mysql_connect("luna","maggot","fzr400dead"); $result = mysql("services","SELECT * FROM organization WHERE uid=$uid"); $org = mysql_result($result,0,"org"); echo "Contact Information For $org"; echo ""; echo ""; echo "

Contact Information for $org

"; echo ""; echo ""; echo "\n"; echo ""; echo "\n"; echo ""; echo "\n"; $email = mysql_result($result,0,"email"); echo ""; echo "\n"; echo "
Name"; echo mysql_result($result,0,"org"); echo "
Phone"; echo mysql_result($result,0,"phone"); echo "
Fax"; echo mysql_result($result,0,"fax"); echo "
Email Address $email"; echo "
"; echo "
"; echo " \n"; echo " \n"; echo "
"; echo "


"; echo "

Services available from this provider

"; echo "
"; $result = mysql("services","SELECT * FROM service WHERE uid=$uid"); $total_rows = mysql_numrows($result); $counter = 0; echo ""; echo ""; while($counter < $total_rows) { echo ""; $counter = $counter + 1; } echo "
Date EnteredServices Available
"; echo mysql_result($result,$counter,"entry_date"); echo ""; echo mysql_result($result,$counter,"service"); echo "
"; echo "

Add new service below."; echo "

"; echo "


"; echo "

"; echo "

"; echo "

"; echo "

"; echo "

"; echo "
"; echo "
\n"; } Function Show_in_Form (){ global $hostname, $password, $user, $state, $org, $email, $phone, $fax, $address1, $address2, $service, $URL, $uid, $first_name, $last_name; mysql_connect("$hostname", "$user", "$password"); $result = mysql("services","SELECT * FROM organization WHERE uid=$uid"); $uid = mysql_result($result,0,"uid"); $org = mysql_result($result,0,"org"); $phone = mysql_result($result,0,"phone"); $fax = mysql_result($result,0,"fax"); $email = mysql_result($result,0,"email"); $URL = mysql_result($result,0,"URL"); $address1 = mysql_result($result,0,"address_1"); echo "

Contact Form

\n"; echo "

\n"; echo " \n"; echo " \n"; echo " Service Organization:

\n"; echo " Phone:

\n"; echo " Fax:

\n"; echo " Campus Address:

\n"; echo " URL:

\n"; echo "

\n"; echo "
\n"; } Function Update_Record (){ global $hostname, $password, $user, $state, $org, $email, $phone, $fax, $address1, $address2, $service, $URL, $uid, $first_name, $last_name; mysql_connect("luna","maggot","fzr400dead"); $result = mysql("services","UPDATE organization SET org = '$org', phone = '$phone', fax = '$fax', email = '$email', address_1 = '$address1', address_2 = '$address2', URL = '$URL' WHERE uid = $uid"); $state = ""; Show_Full_Record($uid); } Function Append_Service (){ global $hostname, $password, $user, $state, $org, $email, $phone, $fax, $address1, $address2, $service, $URL, $uid, $first_name, $last_name; mysql_connect("luna","maggot","fzr400dead"); $result = mysql("services","SELECT now()"); $now = mysql_result($result,0,"now()"); $result = mysql("services","INSERT INTO service (uid, entry_date, service) VALUES ('$uid', '$now', '$service')"); $state = ""; Show_Full_Record($uid); } /* The main loop. Call functions based on the value of $state, which gets set via a hidden INPUT TYPE. */ switch($state) { case ""; start_page(); break; case "list"; Show_Table(); break; case "create"; Empty_Form(); break; case "insert"; Insert_Record (); break; case "edit"; Show_Table(); break; case "fullrecord"; Show_Full_Record(); break; case "update"; Show_in_Form($state, $uid); break; case "addchanges"; Update_Record(); break; case "appendservice"; Append_Service($service); break; case "search"; break; } ?>