【PHP】租贷包包系统

花了三天时间写了一个租贷包包的系统,布局搞的比较辛苦,页面设计也很烧脑 

 index.php




    
    
    
    包包租贷系统



添加客户

租贷包包

归还包包

添加包包

最佳客户

【PHP】租贷包包系统_第1张图片

 add_customer.php




    
    
    用户注册
    


Registered Customers

query($sql); if ($result == 1) echo ''; else echo ''; } ?>
">

【PHP】租贷包包系统_第2张图片

 LuxuryBags.php




    
    
    租贷包包
    


Leasing luxury

query($sql); if ($result == 1) echo ''; else echo ''; } $sql = "SELECT * FROM bag"; if (isset($_POST['colorFilter'])) { $colorFilter = $_POST['colorFilter']; if ($colorFilter !== 'all') $sql = "SELECT * FROM bag WHERE color = '$colorFilter'"; } if (isset($_POST['designerFilter'])) { $designerFilter = $_POST['designerFilter']; $id = getDesignerID($designerFilter); if ($designerFilter !== 'all') $sql = "SELECT * FROM bag WHERE designer_id = $id"; } $result = $conn->query($sql); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { if ($row['rent'] == 0) { $url = "rend.php?bag_id=" . urlencode($row["bag_id"]); echo '
'; echo '' . $row["type"] . ''; echo '' . $row['; echo '$' . getPrice($row['designer_id']) . ''; echo '
'; } } } else { echo "0 results"; } $conn->close(); ?>

【PHP】租贷包包系统_第3张图片

 rend.php






    选择客户
    
    


Chose Customers

')"> $value) { ?>

【PHP】租贷包包系统_第4张图片

【PHP】租贷包包系统_第5张图片

return_bag.php

query($sql);
    if ($result == 1) {
        $sql = "select datediff(return_date,rental_date) as time from rental where rental_id=$id";
        $result = $conn->query($sql);
        $row = $result->fetch_assoc();
        $time = $row['time'];
        $sql = "select price from designer where designer_id = (select designer_id from bag where bag_id=(select bag_id from rental where rental_id=$id))";
        $result = $conn->query($sql);
        $row = $result->fetch_assoc();
        $price = $row['price'];
        echo '';
    } else
        echo '';
}
$tableData = getTableData('rental');
$has=getNoReturnLength();
?>




    归还包包
    
    


Return Bags

0) {?> $value) { ?>

There is no rental.

【PHP】租贷包包系统_第6张图片

 add.php




    
    
    添加包包
    


Add Bags

query($sql); if ($result == 1) echo ''; else echo ''; } ?>
">

【PHP】租贷包包系统_第7张图片 view_customers.php






    最佳客户
    


Best Customers

$value) { ?>
last_name first_name address telephone total_length_of_rental

每个页面都引入的和数据库交互的database.php

connect_error) {  //数据库连接失败弹出提示
    echo '';
    die(); //终止代码
}
function getPrice($id)
{
    global $conn;
    $sql = "select price from designer where designer_id = $id";
    $result = $conn->query($sql);
    $row = $result->fetch_assoc();
    return $row['price'];
}

function getDesignerID($name)
{
    global $conn;
    $sql = "select designer_id from designer where name = '$name'";
    $result = $conn->query($sql);
    $row = $result->fetch_assoc();
    return $row['designer_id'];
}

function getBestCustomers()
{
    global $conn;
    $sql = "call BestCustomers()";
    $result = $conn->query($sql);
    $tableData = array();
    if ($result->num_rows > 0) {
        while ($row = $result->fetch_assoc()) {
            $tableData[] = $row;
        }
    }
    return $tableData;
}

function getNoReturnLength()
{
    global $conn;
    $sql = "select count(*) from rental where return_date is NULL";
    $result = $conn->query($sql);
    $row = $result->fetch_assoc();
    return $row['count(*)'];
}

function getTableLength($tableName)
{
    global $conn;
    $sql = "select count(*) from $tableName";
    $result = $conn->query($sql);
    $row = $result->fetch_assoc();
    return $row['count(*)'];
}

function getTableData($tableName)
{
    global $conn;
    $sql = "select*from $tableName";
    $result = $conn->query($sql);
    $tableData = array();
    if ($result->num_rows > 0) {
        while ($row = $result->fetch_assoc()) {
            $tableData[] = $row;
        }
    }
    return $tableData;
}

function getTableHeader($tableName)
{
    global $conn;
    $sql = "describe $tableName";
    $result = $conn->query($sql);
    $tableHeader = array();
    if ($result) {
        while ($row = $result->fetch_assoc()) {
            $tableHeader[] = $row['Field'];
        }
    }
    return $tableHeader;
}

?>

除此之外,MySQL上实现了几个存储过程和两个触发器

【PHP】租贷包包系统_第8张图片

 

触发器,当rental表被更新时,自动更新bag表中相应包包的租借状态,还回去了

【PHP】租贷包包系统_第9张图片

触发器,当rental被插入时,自动更新bag表中相应包包的租借状态,被借走了

【PHP】租贷包包系统_第10张图片

你可能感兴趣的:(PHP,MySQL数据库系统,php,前端,后端,数据库)