title: How do I pass data values to a form?
body: <p>I have an application I am working on for a fantasy football site. If you go here:</p>
  
  <p><a href="http://digitaldemo.net/kickass/a-results.php" rel="nofollow">http://digitaldemo.net/kickass/a-results.php</a></p>
  
  <p>You can see what the admin will see when they go to view / edit players. </p>
  
  <p>UPDATE--------------------------------------</p>
  
  <p>This is the relevant code on a-results.php that renders the data and <em>should</em> pass data on to the form on qb-edit.php:</p>
  
  <pre><code>&lt;table cellspacing="0" cellpadding="5" border="1" width="560"&gt;
  &lt;tr style="text-align:center"&gt;
  &lt;td style="text-align:left ; width:175px"&gt;Player Name&lt;/td&gt;
  &lt;td&gt;Team&lt;/td&gt;
  &lt;td&gt;Pass Yds&lt;/td&gt;
  &lt;td&gt;Pass TDs&lt;/td&gt;
  &lt;td&gt;Int Thrown&lt;/td&gt;
  &lt;td&gt;Rush Yds&lt;/td&gt;
  &lt;td&gt;Rush TDs&lt;/td&gt;
  &lt;td&gt;Overall Pts&lt;/td&gt;
  &lt;td&gt;TFP&lt;/td&gt;
  &lt;/tr&gt;
  &lt;?php
  $result = mysql_query("SELECT ID, Player, Team, Pass_Yds, Pass_TDs, Int_Thrown, Rush_Yds, Rush_TDs, Overall_Pts, Total_Fantasy_Pts FROM ff_projections WHERE Position = 'QB' ORDER BY Pass_Yds DESC;");
  
  while($row = mysql_fetch_array($result))
  {
  echo "&lt;tr style=\"text-align:center\"&gt;&lt;td style=\"text-align:left\"&gt;{$row['Player']}&lt;/td&gt;";
  echo "&lt;td&gt;{$row['Team']}&lt;/td&gt;";
  echo "&lt;td&gt;{$row['Pass_Yds']}&lt;/td&gt;";
  echo "&lt;td&gt;{$row['Pass_TDs']}&lt;/td&gt;";
  echo "&lt;td&gt;{$row['Int_Thrown']}&lt;/td&gt;";
  echo "&lt;td&gt;{$row['Rush_Yds']}&lt;/td&gt;";
  echo "&lt;td&gt;{$row['Rush_TDs']}&lt;/td&gt;";
  echo "&lt;td&gt;{$row['Overall_Pts']}&lt;/td&gt;";
  echo "&lt;td&gt;{$row['Total_Fantasy_Pts']}&lt;/td&gt;";
  echo "&lt;td&gt;&lt;form action=\"qb-edit.php\" method=\"post\"&gt;&lt;input type=\"hidden\" name=\"ID\" value=\"". $row['ID'] ."\"&gt;&lt;input type=\"submit\" name=\"submit\" value=\"Edit\"&gt;&lt;/form&gt;&lt;/td&gt;&lt;/tr&gt;";
  }
  ?&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>and this is the contents of qb-edit.php:</p>
  
  <pre><code>&lt;?php
  $posted_id = $_POST['ID'];
  ?&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;title&gt;Untitled Document&lt;/title&gt;
  &lt;style&gt;
  body    { font-family:Arial, Helvetica, sans-serif ;
  font-size:14px ;
  }
  
  .form   { width:350px ;
  margin-auto ;
  }
  
  label   { clear:both ;
  display:block ;
  float:left ;
  padding-right:8px ;
  line-height:26px ;
  }
  
  input[type=text]    { float:right ;
  width:163px ;
  height:18px ;
  margin:3px 0px ;
  } 
  
  input[type=text].short  { width:30px ;
  margin-right:132px ;
  }
  
  input[type=submit]  { clear:both ;
  float:left ;
  margin-top:20px ;
  margin-bottom:20px ;
  }
  
  select  { float:right ;
  margin-right:118px ;
  }
  &lt;/style&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;div class="form"&gt;            
  &lt;?php 
  
  echo $posted_id;
  
  $result = mysql_query($connect, "SELECT * FROM ff_projections where ID='" . $posted_id . "'") or die ("Error in query");
  if ($row = mysql_fetch_array($result)) {
  
  echo "&lt;form method='post' action='add_player.php'&gt;";
  echo "&lt;label for='Player'&gt;Player Name:&lt;/label&gt; &lt;input type='text' name='Player' value='" . $row['Player'] . "' /&gt;";
  echo "&lt;label for='Pass_Yds'&gt;Pass Yds:&lt;/label&gt; &lt;input class='short' type='text' name='Pass_Yds' value='" . $row['Pass_Yds'] . "' /&gt;";
  echo "&lt;label for='Pass_TDs'&gt;Pass TDs:&lt;/label&gt; &lt;input class='short' type='text' name='Pass_TDs' value='" . $row['Pass_TDs'] . "' /&gt;";
  echo "&lt;label for='Int_Thrown'&gt;Int Thrown:&lt;/label&gt; &lt;input class='short' type='text' name='Int_Thrown' value='" . $row['Int_Thrown'] . "' /&gt;";
  echo "&lt;label for='Rush_Yds'&gt;Rush Yds:&lt;/label&gt; &lt;input class='short' type='text' name='Rush_Yds' value='" . $row['Rush_Yds'] . "' /&gt;";
  echo "&lt;label for='Rush_TDs'&gt;Rush TDs:&lt;/label&gt; &lt;input class='short' type='text' name='Rush_TDs' value='" . $row['Rush_TDs'] . "' /&gt;";
  echo "&lt;label for='Overall_Pts'&gt;Overall Pts:&lt;/label&gt; &lt;input class='short' type='text' name='Overall_Pts' value='" . $row['Overall_Pts'] . "' /&gt;";
  echo "&lt;input type='submit' name='submit' value='Update Player' /&gt;";
  echo "&lt;input type='hidden' name='id' value='" . $row['ID'] . "' /&gt;";
  echo "&lt;/form&gt;";
  }
  ?&gt;
  &lt;/div&gt;
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I get an error that says:</p>
  
  <pre><code>PHP Warning:  mysql_query() expects parameter 2 to be resource, string given in C:\\xampp\\htdocs\\kickass\\qb-edit.php on line 55, referer: http://localhost/kickass/a-results.php
  </code></pre>
  
  <p>This is line 55 of qb-edit.php:</p>
  
  <pre><code>$result = mysql_query($connect, "SELECT * FROM ff_projections where ID='" . $posted_id . "'") or die ("Error in query");
  </code></pre>
  
  <p>I'm going nuts trying to get this to work...</p>