上一页(添加为编辑)
<!DOCTYPE html>
<html lang="en">
<head>
<script src="jquery-2.1.1.min.js"></script>
<script src="jquery/jquery-ui-1.11.2/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="jquery/jquery-ui-1.11.2/jquery-ui.css">
<link rel="stylesheet" type="text/css" href="bootstrap-3.3.1-dist/dist/css/bootstrap-theme.css">
<link rel="stylesheet" type="text/css" href="bootstrap-3.3.1-dist/dist/css/bootstrap-theme.min.css">
<link rel="stylesheet" type="text/css" href="bootstrap-3.3.1-dist/dist/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="bootstrap-3.3.1-dist/dist/css/bootstrap.min.css">
<script src="bootstrap-3.3.1-dist/dist/js/bootstrap.js"></script>
<script src="bootstrap-3.3.1-dist/dist/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="/CSS/handover.css">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>IgG Dashboard</title>
<script>
$(document).ready(function() {
// Datepicker Popups calender to Choose date.
$(function() {
$("#datepicker").datepicker({ dateFormat: 'yy-mm-dd' });
});
});
</script>
<!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
<!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
<script src="../../assets/js/ie-emulation-modes-warning.js"></script>
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="Dashboard.php">IgG Dashboard</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="adm.php">Messages</a></li>
<li><a href="scriptadd.php">Scripts and Options Editor</a></li>
<li><a href="adm.php">Add User</a></li>
<li id= "dash"><p >Welcome <?php echo " " .$_SESSION['myuser']." ";?><a class="btn bg-info" href="Dashboard.php">Main Site</a></p></li>
</ul>
</div><!-- /.nav-collapse -->
</div><!-- /.container -->
</div><!-- /.navbar -->
<div class="jumbotron">
<div class="container-fluid">
<br>
<br>
<br><br>
<?php
$scripte = ($_POST["scriptake"]);
$scriptot =($_POST["scriptot"]);
include 'config.php';
echo '<h2>'.$scripte.' Equipment</h2>';
echo '<h2>Total Hours '.$scriptot.'</h2>';
echo'<table class="table table-responsive"><tr><form action="equiptest.php" method="post"><th>Script Hour</th><th>Equipment Required</th><th>Stage</th></tr>';
$x = 1;
$p = 1;
$r=1;
while($x <= $scriptot ) {
echo "<tr><td>".$x++."</td><td><input name='equip".$r++."'` ></td><td><input name='stage".$p++."'><input name='ohyeah' type='hidden' value= '".$scriptot."'></td></tr>";
}
echo'<tr><td colspan="2"><input type="submit" class="btn btn-primary"></td></tr></form></table>';
?>
</div>
我可以使用post变量执行此操作。我得到了不确定。但是,如果我写
equip1 = ($_POST["equip1"]);
echo $equip1;
它有效
<?php
$scriptot = ($_POST["ohyeah"]);// working
$y = 1;
$x = 1;
$r= 1;
while($x <= $scriptot ) {//working
${"equip".$x} = ($_POST["equip".$x]); //not working
echo ${"equip" .$x};//not working
$x++; // working
}
我正在尝试创建动态变量。在这种情况下的想法是将POST插入数据库 所以想要 $ equip1 $ equip2 $ equip3等 感谢
答案 0 :(得分:1)
出于组织目的,您应该使用数组。
例如,在表单中,您可以将输入名称设置为“equip [1]”,该值将导入到PHP $_POST['equip'][1]
。然后你可以运行:
foreach($_POST['equip'] as $key=>$value) {
# where $key = 1, the $value will be of equip[1]
}
可能不完全是你所追求的,但它似乎比你正在尝试的解决方案更清晰。
答案 1 :(得分:0)
我就是这样尝试的。
<?php while ( have_posts() ) : the_post(); ?>
<div class="contentTitle"><?php the_title(); ?></div>
<div class="contentText">
<?php the_content(); ?>
</div>
<?php endwhile ?>