<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>修改数据</title>
</head>
<body background="../../images/DNA1.jpg">
    <style>
        .aa {
            font-family: 楷体;
            font-size: 2.5rem;
            position: absolute;
            top: 50px;
            left: 250px;
            background: transparent;
            text-shadow: 0 0 4px rgb(155, 116, 116),
                0 0 4px rgb(155, 116, 116),
                0 0 4px rgb(155, 116, 116);
        }
<pre><code>    .ab {
        font-family: 楷体;
        font-size: 2.5rem;
        position: absolute;
        top: 50px;
        left: 250px;
        background: transparent;
        text-shadow: 0 0 4px rgb(155, 116, 116),
            0 0 4px rgb(155, 116, 116),
            0 0 4px rgb(155, 116, 116);
    }
   .zong{
    display:flex;
    width:100%;
    height:500px;
   }
   .ac {
    display: flex;
    flex-direction: row;
    width: 450px;
    height: 500px;
    margin-top: 100px;
    margin-left: 100px;
    border: 3px solid rgb(149, 108, 108);
    border-radius: 50px;
    background-color: rgb(211, 208, 206);
    justify-content: center;
    align-items: center;
}
    .ad {
    width: 700px;
    height: 500px;
    margin-top: 100px;
    margin-left: 50px;
    border: 3px solid rgb(149, 108, 108);
    border-radius: 50px;
    background-color: rgb(211, 208, 206);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

    .abc {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        font-size: 1.5rem;
        font-family: 楷体;
        margin-top: 5px;
    }

    .query-menu {
        width: 400px;
        height: 40px;
        margin-bottom: 25px;
        margin-left: 30px;
        align-self: flex-start;
    }

    .modify-data input {
        width: 400px;
        height: 40px;
        margin-bottom: 25px;
        margin-left: 30px;
    }

    .normal-button {
        width: 200px;
        height: 50px;
        border-radius: 30px;
        background-color: rgb(97, 151, 97);
        text-align: center;
        margin-top: 25px;
        margin-left: 30px;
    }
&lt;/style&gt;
&lt;div class=&quot;zong&quot;&gt;
&lt;div class=&quot;ac&quot;&gt;
    &lt;div class=&quot;aa&quot;&gt;修改数据&lt;/div&gt;

    &lt;div class=&quot;abc&quot;&gt;
        &lt;form action=&quot;modify-table2.php&quot; method=&quot;post&quot; id=&quot;query-num-form&quot;&gt;
            &lt;h3&gt;修改数据&lt;/h3&gt;
		&lt;select name=&quot;query-menu&quot; class=&quot;query-menu&quot;&gt;
			&lt;option value=&quot;Organization_type&quot;&gt;公司类型&lt;/option&gt;
			&lt;option value=&quot;Entity&quot;&gt;公司名&lt;/option&gt;
		&lt;/select&gt;
		&lt;div class=&quot;modify-data&quot;&gt;
		  修改数据的编号/公司名:
			&lt;input type=&quot;text&quot; name=&quot;input1&quot; placeholder=&quot;请输入...&quot;&gt;
		&lt;/div&gt;
		&lt;div class=&quot;modify-data&quot;&gt;
		  修改为:
			&lt;input type=&quot;text&quot; name=&quot;input2&quot; placeholder=&quot;请输入...&quot;&gt;
		&lt;/div&gt;
            &lt;button type=&quot;submit&quot; class=&quot;normal-button&quot;&gt;提交&lt;/button&gt;
            &lt;button type=&quot;button&quot; onclick=&quot;window.location.href = '../index.php'&quot; style=&quot;width:150px;height:50px;border-radius: 30px;background-color: rgb(97, 151, 97);text-align: center;margin-top: 5px;&quot;&gt;返回上一个页面&lt;/button&gt;
        &lt;/form&gt;
    &lt;/div&gt;
&lt;/div&gt;
    &lt;div class=&quot;ad&quot;&gt;
    &lt;?php
    //including the Mysql connect parameters.
    $link = mysqli_connect(&quot;localhost&quot;, &quot;admin&quot;, &quot;admin&quot;, &quot;data_breach&quot;);
    if (!$link) {
        die(&quot;连接失败: &quot; . mysqli_connect_error());
    }

    if (isset($_POST['query-menu']) &amp;&amp; isset($_POST['input1'])) {
        $name = $_POST['query-menu'];
        $Entity= mysqli_real_escape_string($link, $_POST['input1']);
	$value_new = mysqli_real_escape_string($link, $_POST['input2']);
	// 关闭自动提交 
	mysqli_autocommit($link, FALSE);
	// 获取表名
	$table_sname_query = &quot;SELECT table_sname FROM connection WHERE columns_sname='$name'&quot; ;
	$table_sname_result = mysqli_query($link, $table_sname_query);
	$table_sname_row = mysqli_fetch_assoc($table_sname_result);//将查询结果返回到数组中
	$table_sname = $table_sname_row['table_sname'];//只获取table_name
	if($name==&quot;Year&quot; or $name==&quot;Records&quot;){
		$value_new=(int)$value;
		$delete_query = &quot;UPDATE company SET $name=$value_new WHERE Entity=$Entity&quot;;
		$result = mysqli_query($link, $delete_query);
	}else{
		$delete_query = &quot;UPDATE company SET $name=$value_new WHERE Entity='$Entity'&quot;;
		$result = mysqli_query($link, $delete_query);
	}

        if ($result &amp;&amp; mysqli_affected_rows($link) == 1) {
            mysqli_commit($link);
            //mysqli_close($link);
            echo &quot;&lt;script&gt;window.location.href = 'index.php';&lt;/script&gt;&quot;;
        } else {
            echo $result;
            //echo mysqli_affected_rows($link);
            mysqli_rollback($link);
            mysqli_close($link);
            echo 'false';
            echo gettype($value);
            echo  $value;
        }
    } else {
    }

    // 获取表中数据 这里是自动提交
    $select_query = &quot;SELECT * FROM company order by Entity desc limit 10&quot;;
    $select_result = mysqli_query($link, $select_query);
    $data = array();
    while ($row = mysqli_fetch_assoc($select_result)) {
        $data[] = $row;
    }

    echo '&lt;table&gt;';
    // 输出表头
    echo '&lt;tr&gt;';
    foreach ($data[0] as $key =&gt; $value) {
        echo '&lt;th&gt;' . $key . '&lt;/th&gt;';
    }
    echo '&lt;/tr&gt;';
    // 输出数据行
    foreach ($data as $row) {
        echo '&lt;tr&gt;';
        foreach ($row as $value) {
            echo '&lt;td&gt;' . $value . '&lt;/td&gt;';
        }
        echo '&lt;/tr&gt;';
    }
    echo '&lt;/table&gt;';
    mysqli_close($link);
    ?&gt;

&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</code></pre>
</body>
</html>
修改公司数据 - 数据安全平台

原文地址: https://www.cveoy.top/t/topic/oAWS 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录