Jump to content

Record Edit Code.


Xdega

Recommended Posts

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:

 

playerse.jpg

 

 

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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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>";

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.