|
|
#1 |
|
Silver Member
![]() Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 108
|
Hi there,
I have a database for managing points of members. The database is constructed by |id (primary, unique, AI) | name | rank | points | class |123 |name1|Officer|20 |Warrior The list consists of about 30 different id's for each member added to the list. What i want to do is to create bulk actions. So i can mark several/all members and add a set of points to existing points. The form i use is: HTML Code:
<form action="update_bulk.php" method="post" /> <input type="text" name="ud_points" value="Points"/> <input type="submit" value="Quick Edit" /> HTML Code:
<input type='checkbox' name='ud_id' value='$id' />
PHP Code:
What i want is for the script to update the points value of all id's sent to it. Not only paste in the same number but to add the value, so if i write 20 in ud_points i want it to add those to existing value. Anyone who has a clue?
|
|
|
|
|
|
#2 |
|
New Member
![]() Join Date: Jun 2009
Posts: 2
|
Hey
What you could do is retrieve the value from the table, then store it in a variable. then you can use PHP to add the to variables together and then submit this back into the table use something like: $getpoints="SELECT points FROM members WHERE id='$ud_id'"; mysql_query($getpoints); while ($row = mysql_fetch_array($getpoints)) { $currentpoints = $row['points']; } $newpoints = $ud_points + $currentpoints; $query="UPDATE members SET points='$newpoints' WHERE id='$ud_id'"; mysql_query($query); |
|
|
|
|
|
#3 |
|
Banned
![]() Join Date: Apr 2009
Posts: 41
|
author of Zend Technologies’ PHP 101 series for
PHP beginners (http://www.zend.com/php5/abs/), and has extensive experience deploying PHP and MySQL in a variety of different environments (including corporate intranets, high-traffic Internet web sites, and mission-critical thin client applications). |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|