Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 7th, 2003, 03:29 PM
Registered User
 
Join Date: Oct 2003
Location: Dillon, SC, USA.
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>

Reply With Quote
  #2 (permalink)  
Old October 7th, 2003, 06:45 PM
Friend of Wrox
Points: 2,570, Level: 21
Points: 2,570, Level: 21 Points: 2,570, Level: 21 Points: 2,570, Level: 21
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: San Diego, CA, USA
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/
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 06:46 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.