Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
|
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 7th, 2003, 03:29 PM
Registered User
 
Join Date: Oct 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Jdbellmon Send a message via MSN to Jdbellmon Send a message via Yahoo to Jdbellmon
Default Select Box update to MySQL

Hi,
This Wrox has changed a bit since I was last here. Well anyway, I was wondering if any of you could help me out.
I created a select box filled with elements from a database. I can pull the data in the select drop down box. But when I post it to the next page it fails to pass the data to the next page so that I can place it into the database.

Here I am trying to pull the players name into the selectbox with the ID as the value. I can do that. Then i would like to take the matching text boxes with the stats and pass it to the next page using the post method. There is where I fail. On my Update page it successfully adds to the database but the fields are blank.

Here's a bit of the code
Can someon tell me what I am doing wrong
=========Enter Stats ================================================== ===================================
<body>
<? $SelcTeam = "Cowboys"; ?>
<form method="post" action="testupdate.php">
  <table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td bgcolor="#000000"><strong>IF THE PASSING
        FIELDS ARE NOT ENOUGH TO ADD ALL PLAYERS, YOU WILL BE PROMPTED LATER TO
        ADD MORE IF NECESSARY.</strong></td>
    </tr>
    <tr>
      <td><div align="center"><strong></strong></div></td>
    </tr>
    <tr>
<tr bgcolor="#FF0000">
            <th colspan="12" nowrap><div align="center">
                <p>PASSING STATS</p>
              </div></th>
          </tr>
          <tr bgcolor="#0000FF">
            <th nowrap>Name</th>
            <th nowrap>Ratings</th>
            <th nowrap>Yards</th>
            <th nowrap>TD</th>
            <th nowrap>Int</th>
            <th nowrap>Comp</th>
            <th nowrap>Att</th>
            <th nowrap>Comp%</th>
            <th nowrap>Avg</th>
            <th nowrap>Yds/<br>
              Game</th>
            <th nowrap>Sack</th>
            <th nowrap>Long</th>
          </tr>
          <tr align="center" valign="middle" bgcolor="#CCCCCC">
            <td nowrap>
              <?
//change the following variables with the appropriate
$host = "localhost";
$dbname = "*********";
$dbpass = "*********";

$connection = mysql_connect("$host","$dbname","$dbpass");
$db = mysql_select_db("$dbname",$connection);

echo"<select name=\"Passing\"><option value=\"RosterPlayer\">Select Player</OPTION>"; //start the select box

$results= mysql_query("SELECT * from Players where Team='".$SelcTeam."'");
$id = PLAYERID;
$idname = NAME;
$idPosition = POS;
$idTeam = TEAM;
echo mysql_error();

if (mysql_Numrows($results)>0) //if there are records in the fields
{
  $numrows=mysql_NumRows($results); //count them
  $x=0;
  while ($x<$numrows){ //loop through the records
    $theId=mysql_result($results,$x,$id); //place each record in the variable everytime we loop
    $theName=mysql_result($results,$x,$idname);
    $thePos=mysql_result($results,$x,$idPosition);
    $theTeam=mysql_result($results,$x,$idTeam);
    echo "<option value=\"$theId\">".$theName." (".$theTeam." ".$thePos.")</option>\n"; //and place it in the select
    $x++;
  }
}
echo "</select>"; //close the select
?>
            </td>
            <td nowrap><input name="PassRatings" type="text" id="PassRatings" size="5" maxlength="85"></td>
            <td nowrap><input name="PassYds" type="text" id="PassYds" size="5" maxlength="85"></td>
            <td nowrap><input name="PassTD" type="text" id="PassTD" size="5" maxlength="85"></td>
            <td nowrap><input name="PassINT" type="text" id="PassINT" size="5" maxlength="85"></td>
            <td nowrap><input name="PassComp" type="text" id="PassComp" size="5" maxlength="85"></td>
            <td nowrap><input name="PassATT" type="text" id="PassATT" size="5" maxlength="85"></td>
            <td nowrap><input name="PassCompPCT" type="text" id="PassCompPCT" size="5" maxlength="85"></td>
            <td nowrap><input name="PassAVG" type="text" id="PassAVG" size="5" maxlength="85"></td>
            <td nowrap><input name="PassYdsGm" type="text" id="PassYdsGm" size="5" maxlength="85"></td>
            <td nowrap><input name="PassSack" type="text" id="PassSack" size="5" maxlength="85"></td>
            <td nowrap><input name="PassLong" type="text" id="PassLong" size="5" maxlength="85"></td>
          </tr>
          <tr align="center" valign="middle">
            <td nowrap>
================================================== ================================================== ============
========Update Stats Page ================================================== =====================================

<body>
<?
//change the following variables with the appropriate
$host = "localhost";
$dbname = "*********";
$dbpass = "*********";

$connection = mysql_connect("$host","$dbname","$dbpass");
$db = mysql_select_db("$dbname",$connection);

mysql_query ("INSERT INTO `verifystats` (PlayerID,Team,GameNumber,Name,Rating,PassYds,Pass Tds,PassInts,PassComp,PassAtt,PassPercent,PassAvg, PassYdsGm,PassSack,PassLong)where `PlayerID`='".$Passing2."'",$connection)
VALUES ('Player',' Team', '0',' Name', $PassRatings, $PassYds, $PassTD, $PassINT, $PassComp, $PassATT, $PassCompPCT, $PassAVG, $PassYdsGm, $PassSack, $PassLong);

//$result=mysql_query
//echo mysql_error()

?>

</body>

 
Old October 7th, 2003, 06:45 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

http://p2p.wrox.com/archive/beginnin...2002-11/17.asp
http://p2p.wrox.com/topic.asp?TOPIC_ID=4944


Take care,

Nik
http://www.bigaction.org/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Select box ? mikedeepak Classic ASP Professional 0 July 20th, 2006 03:43 AM
Fill select box and select recordset value markd Classic ASP Databases 1 February 20th, 2006 06:41 PM
multicolored List Box or Select Box sasidhar79 Javascript 1 February 15th, 2005 01:47 AM
select box/List box alphabetic sort sasidhar79 Javascript How-To 3 November 10th, 2004 03:04 AM
Select Box update to MySQL Jdbellmon Pro PHP 1 October 10th, 2003 12:03 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.