提供HTML和PHP代码 [英] Sequnce of HTML and PHP code

查看:74
本文介绍了提供HTML和PHP代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<html>
<head>
<style>
table, th, td {
    border: 1px solid black;
    border-collapse: collapse;
}
th, td {
    padding: 5px;
    text-align: left;
}
</style>
</head>
<body>
<form method="post">
  <h4>Answer all the questions on the scale (1)Strongly agree to (5)Strongly disagree </h4>
  <table width="1000" border="1" cellpadding="10">
    <tbody>
      <tr>
        <th style="width:50% ; text-align:center" scope="col">Questions</th>
        <th style="width:10% ; text-align:center" scope="col">Strongly agree</th>
        <th style="width:10% ; text-align:center" scope="col">Agree</th>
        <th style="width:10% ; text-align:center" scope="col">Neutral</th>
        <th style="width:10% ; text-align:center" scope="col">Disagree</th>
        <th style="width:10% ; text-align:center" scope="col">Strongly disagree</th>
      </tr>
      <tr>
        <td>1.People are clear about their role and performance levels expected of them.</td>
        <td><input type="radio" name="q1" value="q1a">
          1</td>
        <td><input type="radio" name="q1" value="q1b">
          2</td>
        <td><input type="radio" name="q1" value="q1c">
          3</td>
        <td><input type="radio" name="q1" value="q1d">
          4</td>
        <td><input type="radio" name="q1" value="q1e">
          5</td>
      </tr>
      <tr>
        <td>2.People understand how their role fits with the responsibilities of others.</td>
        <td><input type="radio" name="q2" value="q2a">
          1</td>
        <td><input type="radio" name="q2" value="q2b">
          2</td>
        <td><input type="radio" name="q2" value="q2c">
          3</td>
        <td><input type="radio" name="q2" value="q2d">
          4</td>
        <td><input type="radio" name="q2" value="q2e">
          5</td>
      </tr>
      <tr>
        <td>3.People understand the contribution they are making to organisational objectives.</td>
        <td><input type="radio" name="q3" value="q3a">
          1</td>
        <td><input type="radio" name="q3" value="q3b">
          2</td>
        <td><input type="radio" name="q3" value="q3c">
          3</td>
        <td><input type="radio" name="q3" value="q3d">
          4</td>
        <td><input type="radio" name="q3" value="q3e">
          5</td>
      </tr>
      <tr>
        <td>4.People are clear about the behaviours expected of them in achieving their objectives.</td>
        <td><input type="radio" name="q4" value="q4a">
          1</td>
        <td><input type="radio" name="q4" value="q4b">
          2</td>
        <td><input type="radio" name="q4" value="q4c">
          3</td>
        <td><input type="radio" name="q4" value="q4d">
          4</td>
        <td><input type="radio" name="q4" value="q4e">
          5</td>
      </tr>
      <tr>
        <td>5.Values and attributes are aligned with each other and support critical behaviour such as customer service or innovation.</td>
        <td><input type="radio" name="q5" value="q5a">
          1</td>
        <td><input type="radio" name="q5" value="q5b">
          2</td>
        <td><input type="radio" name="q5" value="q5c">
          3</td>
        <td><input type="radio" name="q5" value="q5d">
          4</td>
        <td><input type="radio" name="q5" value="q5e">
          5</td>
      </tr>
      <tr>
        <td>6.People feel the organisational systems are 'in sync' with their objectives.</td>
        <td><input type="radio" name="q6" value="q6a">
          1</td>
        <td><input type="radio" name="q6" value="q6b">
          2</td>
        <td><input type="radio" name="q6" value="q6c">
          3</td>
        <td><input type="radio" name="q6" value="q6d">
          4</td>
        <td><input type="radio" name="q6" value="q6e">
          5</td>
      </tr>
      <tr>
        <td>7.People believe they are given space to try new ideas or ways of doing things.</td>
        <td><input type="radio" name="q7" value="q7a">
          1</td>
        <td><input type="radio" name="q7" value="q7b">
          2</td>
        <td><input type="radio" name="q7" value="q7c">
          3</td>
        <td><input type="radio" name="q7" value="q7d">
          4</td>
        <td><input type="radio" name="q7" value="q7e">
          5</td>
      </tr>
      <tr>
        <td>8.Knowledge-sharing enables people to learn from one another.</td>
        <td><input type="radio" name="q8" value="q8a">
          1</td>
        <td><input type="radio" name="q8" value="q8b">
          2</td>
        <td><input type="radio" name="q8" value="q8c">
          3</td>
        <td><input type="radio" name="q8" value="q8d">
          4</td>
        <td><input type="radio" name="q8" value="q8e">
          5</td>
      </tr>
      <tr>
        <td>9.Cross-functional working enables people to learn from others' experiences.</td>
        <td><input type="radio" name="q9" value="q9a">
          1</td>
        <td><input type="radio" name="q9" value="q9b">
          2</td>
        <td><input type="radio" name="q9" value="q9c">
          3</td>
        <td><input type="radio" name="q9" value="q9d">
          4</td>
        <td><input type="radio" name="q9" value="q9e">
          5</td>
      </tr>
      <tr>
        <td>10.People watch for changes within the external world that might impact on the organisation.</td>
        <td><input type="radio" name="q10" value="q10a">
          1</td>
        <td><input type="radio" name="q10" value="q10b">
          2</td>
        <td><input type="radio" name="q10" value="q10c">
          3</td>
        <td><input type="radio" name="q10" value="q10d">
          4</td>
        <td><input type="radio" name="q10" value="q10e">
          5</td>
      </tr>
    </tbody>
  </table>
  <input type="submit" id="submit" name="submit">
</form>
</body>
</html>







$servername = "localhost";
$username = "root";
$password = "*********";
$dbname = "survey";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 

// Create database
$sql = "CREATE DATABASE alignment";
if ($conn->query($sql) === TRUE) {
    echo "Database created successfully";
} else {
    echo "Error creating database:alignment " . $conn->error;
}

$conn->close();

// create table
$sql = "CREATE TABLE survey (
sid INT(20) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
q1 VARCHAR(20) NOT NULL,
q2 VARCHAR(20) NOT NULL,
q3 VARCHAR(20) NOT NULL,
q4 VARCHAR(20) NOT NULL,
q5 VARCHAR(20) NOT NULL,
q6 VARCHAR(20) NOT NULL,
q7 VARCHAR(20) NOT NULL,
q8 VARCHAR(20) NOT NULL,
q9 VARCHAR(20) NOT NULL,
q10 VARCHAR(20) NOT NULL,
)";

if ($conn->query($sql) === TRUE) {
    echo "Table survey created successfully";
} else {
    echo "Error creating table: " . $conn->error;
}

$conn->close();


//insert values
$sql = "INSERT INTO survey (sid, q1, q2, q3, q4, q5, q6, q7, q8, q9, q10,)
VALUES (' ', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?')";

if ($conn->query($sql) === TRUE) {
    echo "New record created successfully";
} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
?>





What I have tried:



first i had only the html code. I dont know much of php and db still i managed to write some code. But i dont know the sequence for it. Also i tried executing it but it shows errors. It is not connecting to database on xampp. Please can someone tell me where i am going wrong.



What I have tried:

first i had only the html code. I dont know much of php and db still i managed to write some code. But i dont know the sequence for it. Also i tried executing it but it shows errors. It is not connecting to database on xampp. Please can someone tell me where i am going wrong.

推荐答案

servername = \"localhost\";
servername = "localhost";


用户名 = ;
username = "root";


password = \"*********\";
password = "*********";


这篇关于提供HTML和PHP代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆