Link to home
Start Free TrialLog in
Avatar of sys_admin_pic
sys_admin_pic

asked on

Using a HTML table to update mysql records

Hi,

I am currently designing a website that will display league standings, sorted by point value. I have worked out how I can display the data in a table now and in the way that I want, but the website has to be updatable. Is it possible to design a table that will update points when entered into a field?

For example, would it be possible to grab the team names and place them in a dropdown menu, then use a seperate text field to input the point value, click submit which would add that value onto the existing value for the relevant team?

Either that, or display the teams in a list on a page so you can edit multiple records at any one time?

I have been looking around but I am struggling at the moment to find an answer

The fields I am using in my table are:

tname  - team name
points - current points.

Many Thanks
Matt
ASKER CERTIFIED SOLUTION
Avatar of krv123
krv123
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sys_admin_pic
sys_admin_pic

ASKER

Hi KRV123 - many thanks for your help.

Looks brilliant, but also I am getting an error on the following line:
$result = mysql_error($sql)or die(mysql_error());

Error as follows:
Warning: mysql_error(): supplied argument is not a valid MySQL-Link resource in E:\websvr\hosttest.php on line 36

Can you offer any help?

Thanks
Matt
Thats for that answer krv123. I have been playing with the code and have got it working now :)

There was a miss type on {$tId[$i]} - should have read {$teamId[$i]} so not to worry.

Just a quick one though - is there any way of getting the form to just add values on to the end, ie, start with blank fields and add on only the fields that have been filled in?

For example:

Team 1 gets 10 points, so you enter 10 in team 1's field - that adds on when you click update, but ignores all of the other empty fields in the form?

Thanks
Matt
Also,

When you click update - it prints "updated" 7 times across the page

Thanks
Matt
Take the echo out of the for loop. and as far as your other question about only updated the values you entered, you would have to use checkboxes. they are not fun when you have to check 10 + line items
Sure no problems, I am sure they can cope on it as it is!

Great answer - points are all yours...

Cheers
Matt
Just a quick clarification - I have entered a action="sitetest.php" into the form bracket, so when I click update, it refreshes the table.

I notice that it doesnt refresh the whole page - is there a way to do this?

Thanks
Matt
what browser are you using?
I have tested it in IE and Firefox