Xdega Posted October 4, 2010 Share Posted October 4, 2010 Hey. So basically I am working on a simple project, I am no PHP expert, I only know a bit of the basics. This project is simply a "performance monitor" script. I have the parts to add records etc. I am now starting to tackle the next phase of the project that is to modify the records to give "infractions" or "bonus". I want to keep this simple and have the following fields on the edit form: PLAYER NAME: Dropdown List of the PLAYER_NAME column on my table called players I grabbed this code from a different thread (and edited it in an attempt to match my table). echo "Select a name: <select name='$name'>"; $query="select PLAYER_NAME from PLAYERS"; $result=mysql_query($query); while($row=mysql_fetch_array($result)){ $name=$row['PLAYER_NAME']; echo "<option value='$name'>$name</option>"; } echo "</select>"; I tried to understand it as I modified it, but aparently I misunderstood it becuase it's not working right, this gives me nothing but an empty dropdown box. Here is a screenshot of my current "players" table, so you can see the structure and what not: INFRACTION/BONUS A box to add or subtract "points". I am thinking along the lines of a number text entry with a radio button for options for either BONUS(add) or INFRACTION (subtract) NOTES Just a simple text box for comments. TIMESTAMP I will do this easily with a field on the SQL table What is wrong with the above PHP code I have for the dropdown box? Also how would I go about making this a usable form? I simply want to create new records with all of the above data on a new table I will create called "infractions". I then want to use the data from the "INFRACTION/BONUS" Field to edit the "ND_POINTS" value on the players table. I know the post is a little long, but I would appreciate any help and guidance you can offer in this project. Thanks. Quote Link to comment Share on other sites More sharing options...
BillyBoB Posted October 4, 2010 Share Posted October 4, 2010 Could you post more of your code? This doesn't help much. Quote Link to comment Share on other sites More sharing options...
Xdega Posted October 4, 2010 Author Share Posted October 4, 2010 The code I posted is the code I have for the "dropdown box". I have no more code for the rest of the form. I am simply asking for help with the script I have posted. What is wrong with the code.? How do I make this a working dropdown list that can be used as part of the "edit form" I am trying to achieve. That is all I have. I posted a screenie of the table that I am using also. The includes are just working scripts for connecting to the DB. Selecting the "players" table. and a nav bar. These parts are all working and not what I am asking for help with. Quote Link to comment Share on other sites More sharing options...
BillyBoB Posted October 4, 2010 Share Posted October 4, 2010 Other than the name of the select isn't going to be established since $name is further down from line 1 the code is fine. In that small section of code I can't see if you're connecting to a db before it or what tables are listed in the db. I can't help you any further. Quote Link to comment Share on other sites More sharing options...
Xdega Posted October 4, 2010 Author Share Posted October 4, 2010 Other than the name of the select isn't going to be established since $name is further down from line 1 the code is fine. In that small section of code I can't see if you're connecting to a db before it or what tables are listed in the db. I can't help you any further. ok. Here is the contents of the previous Includes: dbopen.php <?php $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); mysql_select_db($dbname); ?> The config is just the variables with my server info (used in the above code). Not posting that, lol Quote Link to comment Share on other sites More sharing options...
BillyBoB Posted October 4, 2010 Share Posted October 4, 2010 ok after looking it over try: echo "Select a name: <select name='$name'>"; $query="select * from PLAYERS"; $result=mysql_query($query); while($row=mysql_fetch_array($result)){ $name=$row['PLAYER_NAME']; echo "<option value='$name'>$name</option>"; } echo "</select>"; Quote Link to comment Share on other sites More sharing options...
Xdega Posted October 4, 2010 Author Share Posted October 4, 2010 still not working. Empty Dropdown box. Quote Link to comment Share on other sites More sharing options...
Xdega Posted October 4, 2010 Author Share Posted October 4, 2010 got it. the "PLAYERS" was case sensitive Quote Link to comment Share on other sites More sharing options...
Xdega Posted October 4, 2010 Author Share Posted October 4, 2010 one more thing. I am thankful for the assistance thus far. Now all I need is help on how to make this part of a form, where I can submit data via the $_POST method and use the data to edit my tables etc. I can work on the next part. Just want assistance on how to make the rest of my form. thx again. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.