Web Design Forum  
 
Go Back   Web Design Forum > Web Software > Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 06-15-2009, 09:10 AM   #1
Silver Member
 
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 108
Default PHP/MYSQL Bulk Actions

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" />
And for each member they get:
HTML Code:
<input type='checkbox' name='ud_id' value='$id' />
Now, this form is being sent to update_bulk.php witch look like this:
PHP Code:
$ud_id=$_POST['ud_id'];
$ud_points=$_POST['ud_points'];

require_once(
'mysql.php');

$query="UPDATE members SET points='$ud_points' WHERE id='$ud_id'";
mysql_query($query); 
Now, i'm a real noob when it comes to PHP/Mysql, so i could really use some help with this PHP/Mysql action.

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?
__________________
Nerdrage
Mezangath Web
mezangath is offline   Reply With Quote


Old 06-27-2009, 12:42 AM   #2
New Member
 
Join Date: Jun 2009
Posts: 2
Default

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);
anthwinter is offline   Reply With Quote
Old 06-27-2009, 05:48 AM   #3
Banned
 
Join Date: Apr 2009
Posts: 41
Default

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).
Lonny Earl is offline   Reply With Quote
Reply

Thread Tools
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 05:24 AM.


Camera Forum - Computer Forum - Web Design Forum

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO 3.6.0 ©2011, Crawlability, Inc.