Q:

php while loop for dynamic post variables

previous page (added as edit)
<! 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>

Can I do this with a post variable.  I get undefined.  However if I write 
 equip1 = ($_POST["equip1"]);
 echo $equip1;

it works
<? 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
 }

I am trying to create dyanmic variables.  Idea in this case is to insert POST to database
so want 
    $equip1
    $equip2
    $equip3 etc
  Thanks

A:

For organizational purposes, you should really use arrays. 
For instance, in a form you can set the input name to 'equip[1]' and the value will imported to PHP as $_POST['equip'][1].   Then you can just run:
foreach($_POST['equip'] as $key=>$value) {
   # where $key = 1, the $value will be of equip[1]
}

May not be exactly what you're after, but it seems like a much cleaner solution than what you are attempting.