21,886
社区成员
发帖
与我相关
我的任务
分享
<html>
<head>
<title>Sales Rep Maintenance</title>
</head>
<?php
// Address error handling
ini_set('display_errors',1);
error_reporting(E_ALL & ~E_NOTICE);
// Attempt to Connect
if ($connection = @mysql_connect ('localhost', '***', '***')){
print '<p>Successfully connected to MySQL.</p>';
//mysql_close(); // close the connection
}
else {
die('<p>Could not connect to MySQL because: <b>' .mysql_error() .
'</b></p>');
}
if (@mysql_select_db("PREMIERE", $connection)){
print '<p>The PREMIERE database has been selected.</p>';
}
else {
die('<p>Cound not select the PREMIERE database because: <b>' .mysql_error().'</b></p>');
}
if(!$_REQUEST['submit'])
{
generate_form();
}
else if($_REQUEST['submit'] == "Search")
{
search_rep();
}
else if($_REQUEST['submit'] == "Add")
{
add_rep();
}
else if($_REQUEST['submit'] == "Delete")
{
delete_rep();
}
else if($_REQUEST['submit'] == "Update")
{
update_rep();
}
function generate_form()
{
}
function search_rep()
{
// Define the rep Number php variable name
$rep = $_POST['rep_num'];
print "The rep num chosen was $rep<br/>";
// Define the query
$query = "SELECT * FROM REP WHERE CUSTOMER_NUM = '$rep'";
// Output the resulting query table
if ($r = mysql_query($query))
{
while ($row = mysql_fetch_array($r))
{
print "<p>{$row['REP_NUM']}<br/>{$row['LAST_NAME']}<br/>{$row['FIRST_NAME']}<br/>
{$row['STREET']}<br/>{$row['CITY']}<br/>{$row['STATE']}<br/>{$row['ZIP']}<br/>
{$row['COMMISSION']}<br/>{$row['RATE']}<br/></p>\n";
}
}
}
function add_rep()
{
}
function delete_rep()
{
}
function update_rep()
{
}
?>
</html>