Forum Moderators: coopster
Lets say the database is called "traffic".
The table in traffic I need to make changes in is "members"
The field I need to update is "credits"
The problem is I have a lot of members that need the credits field
updated to the same amount.
So I need to be able to put in a form a list of "members"(line by line)
and upon submit it updates each members credit field.
Does anyone know where I can get that form made up?
Does anyone know where I can get that form made up?
But I can tell you how you can create it:
Lets say the database is called "traffic".
The table in traffic I need to make changes in is "members"
The field I need to update is "credits"
Assuming you have made the connection.
$credit = $_REQUEST['credit'];
$member_id = $_REQUEST['member_id'];
If you wish to update one by one:
$query = "UPDATE members SET credits = ". $credit ." WHERE member_id = ". $member_id ."";
mysql_query($query);
If you wish to update many members at once:
You can pass the members list or ids comma separated, explode it, and loop to run the update query a number of times, or include those ids as where conditions in the query.
Habtom
If you wish to update many members at once:
You can pass the members list or ids comma separated, explode it, and loop to run the update query a number of times, or include those ids as where conditions in the query.
That is the part I do not understand.
I need to be able to copy and paste into a form a list of "members" (one per line) and then click a submit button.
Then it takes each member and changes their credits field.
All credit fields will get the same amount.
I can currently do one at a time but I have hundreds to do.
Thanks for the reply.
If you can show me how to do it with a list of members (one per line)I would be so grateful.
I just have no clue about looping or exploding.
$query = "UPDATE members SET credits = ". $credit ." WHERE member_id IN (". $member_id . ")";
then $member_id would need to be a comma seperated list of ids
you could paste them into a textarea and then process that, if you pasted a list of ids seperated by commas then it would be even easier
make a textarea
paste a list in there
then echo it on your processing script to see how it needs to be transformed