请告诉我是否可以做些什么来改进此代码。我对 PHP 真的很陌生,任何指针都将不胜感激。
我一直在为此努力,这对我来说比许多人都大。我真的很感谢那些更有经验的人来看看和批评的人的眼睛。
我的下一步是让相同的脚本处理表单操作并将这些值添加到 MySQL 表中。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Add New Games</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- Le styles -->
<link href="css/bootstrap.css" rel="stylesheet">
<style>
body {
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
}
</style>
<link href="css/bootstrap-responsive.css" rel="stylesheet">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="js/html5shiv.js"></script>
<![endif]-->
<!-- Fav and touch icons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="ico/apple-touch-icon-57-precomposed.png">
<link rel="shortcut icon" href="ico/favicon.png">
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="#">Game Admin Area</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li class="active"><a href="#">Add New Games</a></li>
<li><a href="#about">Update Game Scores</a></li>
<li><a href="#contact">Reports</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<div class="container">
<h1>Add New Games to Database</h1>
<p>Use the form below to quickly add upcoming games to the database.<br>Players will not be able to place their predictions until you inputted these games.</p>
<?php
$dbc = mysql_connect(,,);
$db = mysql_select_db();
$results= mysql_query("SELECT * FROM tbl_teams");
$myHTML = '';
while($row = mysql_fetch_array($results)) {
$myHTML .= '<option value="'.$row['team_ID'].'">'. $row['team_name'].'</option>';
}
$myHTMLdate = '';
for($i = 1; $i <= 14; $i ++){
$startdate = strtotime("today + $i day");
$myHTMLdate .= '<option value="'.date('Y-m-d', $startdate).'">'.date('l', $startdate).', '.date('d M Y', $startdate).'</option>';
}
?>
<div id="wrapper">
<div class="datagrid">
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th>Game No.</th>
<th>Team 1</th>
<th>Vs.</th>
<th>Team 2</th>
<th>Game Date</th>
</tr>
</thead>
<tbody>
<?php
for ($i=1; $i <=30; $i++) {
echo "<tr>
<td>".$i."</td>
<td><select name='game".$i."_team1'>".$myHTML."</select></td>
<td>Vs.</td>
<td><select name='game".$i."_team2'>".$myHTML."</select></td>
<td><select name='game".$i."_date'>".$myHTMLdate."</select></td>
</tr>";
}
?>
</tbody>
</table>
<button class="btn btn-large btn-primary" type="submit">Send these games to the server!</button>
</div>
</form>
</div>
<!-- /container -->
<!-- Javascript -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="js/jquery.js"></script>
<script src="js/bootstrap-transition.js"></script>
<script src="js/bootstrap-alert.js"></script>
<script src="js/bootstrap-modal.js"></script>
<script src="js/bootstrap-dropdown.js"></script>
<script src="js/bootstrap-scrollspy.js"></script>
<script src="js/bootstrap-tab.js"></script>
<script src="js/bootstrap-tooltip.js"></script>
<script src="js/bootstrap-popover.js"></script>
<script src="js/bootstrap-button.js"></script>
<script src="js/bootstrap-collapse.js"></script>
<script src="js/bootstrap-carousel.js"></script>
<script src="js/bootstrap-typeahead.js"></script>
</body>
</html>