使用html创建的网页 使用php连接teradata。
下面是我的html和php代码。
html代码:
<html>
<head>
<style type = "text/css">
table {
font-family: Times New Roman, serif;
border-collapse: collapse;
width: 100%;
}
td, th {
font-family: calibri, serif;
border: 1px solid Red;
text-align: left;
padding: 5px;
}
tr:nth-child(even) {
background-color: whitesmoke;
}
</style>
</head>
<body>
<title>My Web-page</title>
<body bgcolor="white">
<h2>This is sample website which help you to find free machine</h2>
<h2>List of machines</h2>
<table>
<tr>
<th>Machine Name</th>
<th>Release</th>
<th>Status</th>
<th>Machine Owner</th>
<th>Reserved By</th>
<th>For Days</th>
<th>Decision</th>
</tr>
<form id="select_co" name="select_co" method="post" action="check.php">
<tr>
<td>Machine 1</td>
<td>15.10</td>
<td>
<select name="btname">
<option value="Unreserved">Unreserved</option>
<option value="Reserved">Reserved</option>
</select>
</td>
<td>Rubesh</td>
<td>
<input type="text" name="btname1" value="" />
</td>
<td>
<select name="btname2">
<option value="-">-</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</td>
<td>
<input type="submit" name="nw_update" value="NW_Update"/>
</td>
</form>
</tr>
<form id="select_co" name="select_co" method="post" action="check.php">
<tr>
<td>Machine 2</td>
<td>15.10</td>
<td>
<select name="btname">
<option value="Unreserved">Unreserved</option>
<option value="Reserved">Reserved</option>
</select>
</td>
<td>Rubesh</td>
<td>
<input type="text" name="btname1" value="" />
</td>
<td>
<select name="btname2">
<option value="-">-</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</td>
<td>
<input type="submit" name="nw_update" value="NW_Update"/>
</td>
</form>
</tr>
</table>
</body>
</html>
Php代码:
<?php
$btname = (isset($_POST['btname']) ? $_POST['btname'] : 'hi');
echo $_POST['btname'];
$btname1 = (isset($_POST['btname1']) ? $_POST['btname1'] : 'hi');
echo $_POST['btname1'];
$btname2 = (isset($_POST['btname2']) ? $_POST['btname2'] : 'there');
echo $_POST['btname2'];
if(isset($_POST['nw_update']))
{
echo("You clicked button one!");
//and then execute a sql query here
// establish connection
$cn=odbc_connect('teradata','password','password');
if (!$cn)
{
exit("Connection Failed: ".odbc_error().":".odbc_errormsg()."\n");
}
// populate employee table with sample data
if (!odbc_exec($cn, "INSERT INTO dr.t10 ('$btname', '$btname2', '$btname1')"))
{
print("Execution failed - ".odbc_error().":".odbc_errormsg()."\n");
}
}
else
{
echo" dhur";
}
?>
我怀疑的是如何使用更新的一行更改来重新加载我的网页?我希望你能理解我的问题。请有人帮我做同样的事。
提前致谢。 Rubesh G。