View Full Version : Parse $pagetext for members...
Benumbed
02-14-2005, 02:11 PM
Posted this in another forum but I think it might have been wrong one...
Type Names in a textbox, using
print_textarea_row($vbphrase['text'], 'pagetext', $raid['pagetext'], 10, 50, 1, 0);
When you click add attendees, it will parse thru each one and add new record in raid_attendees table.
Example:
(Enter this into pagetext)
Blah
Bleh
Blah2
Bleh2
Blah3
Bleh3
When you hit submit, it will parse thru each with a linebreak and...
add new record in a table for blah
add new record in a table for bleh
add new record in a table for blah2
add new record in a table for bleh2
add new record in a table for blah3
add new record in a table for bleh3
I know its some kind of an array, but cant figure out how to loop it and use each name.
No one? :(
I am doing this in an edited announcement.php file inside modcp if that helps.
Dean C
02-15-2005, 09:54 AM
Try and explain yourself a bit better, screenshot may help :)
Benumbed
02-15-2005, 02:53 PM
print_textarea_row($vbphrase['text'], 'pagetext', $raid['pagetext'], 10, 50, 1, 0);
(Included into screenshot with names in box)
When I hit submit, it will parse thru each line break and ...
Add Benumbed into table "raid_attendees"
Add Renwo into table "raid_attendees"
Add Fila into table "raid_attendees"
Add Valura into table "raid_attendees"
Add Agronom into table "raid_attendees"
Add Ewoc into table "raid_attendees"
Add Eman into table "raid_attendees"
Basically just does a for each (line break) enter name into database.
I know it sounds retarded why I want to do it this way, but I play a game where it takes a copy of raid attendees (which can be 40-50+) and I just paste in a textfile so I can update there attendance (they get rewards, etc).
Dean C
02-15-2005, 08:46 PM
$names = preg_split('/[\r\n]+/', $names);
foreach($names AS $key => $val)
{
// do your queries here
}
Benumbed
02-16-2005, 04:13 AM
$names = preg_split('/[\r\n]+/', $names);
foreach($names AS $key => $val)
{
$attendees['member_name'] = $val;
$attendees['raid_id'] = $raididnow['raid_id'];
$DB_site->query(fetch_query_sql($attendees, 'dkp_raid_attendees '));
How would I call it back into the format it was in for modify raid?
also (sorry, I really am)
How would you parse this:
1 Borr 60 Paladin
1 Fila 60 Warrior
1 Mightyal 59 Warrior
1 Soulss 60 Priest
1 Taparoo 60 Warlock
2 Crazy 60 Paladin Officer
2 Cronis 60 Mage
2 Ewoc 60 Warrior
2 Shortee 60 Rogue
2 Xirro 60 Druid
3 Agronom 60 Paladin
3 Benumbed 60 Priest Raid Leader
3 Souldat 60 Rogue
3 Warv 60 Paladin
and remove everything but the names
Dean C
02-16-2005, 09:01 AM
$names = preg_split('/[\r\n]+/', $names);
foreach($names AS $key => $val)
{
$attendees['member_name'] = $val;
$attendees['raid_id'] = $raididnow['raid_id'];
$DB_site->query(fetch_query_sql($attendees, 'dkp_raid_attendees '));
How would I call it back into the format it was in for modify raid?
also (sorry, I really am)
How would you parse this:
1 Borr 60 Paladin
1 Fila 60 Warrior
1 Mightyal 59 Warrior
1 Soulss 60 Priest
1 Taparoo 60 Warlock
2 Crazy 60 Paladin Officer
2 Cronis 60 Mage
2 Ewoc 60 Warrior
2 Shortee 60 Rogue
2 Xirro 60 Druid
3 Agronom 60 Paladin
3 Benumbed 60 Priest Raid Leader
3 Souldat 60 Rogue
3 Warv 60 Paladin
and remove everything but the names
What is this exactly? Is it a string or databse structure or...? Please try and describe yourself a little better ;)
Benumbed
02-16-2005, 01:01 PM
$names = preg_split('/[\r\n]+/', $names);
foreach($names AS $key => $val)
{
$attendees['member_name'] = $val;
$attendees['raid_id'] = $raididnow['raid_id'];
$DB_site->query(fetch_query_sql($attendees, 'dkp_raid_attendees '));
}
That is the code to place each name in the database seperate from each other (like you gave me the code for. Just when I go to edit/modify the raid, it is all together. Was wondering if there was a code to reverse it back into format of:
Name
Name2
Name3
1 Borr 60 Paladin
1 Fila 60 Warrior
1 Mightyal 59 Warrior
1 Soulss 60 Priest
1 Taparoo 60 Warlock
2 Crazy 60 Paladin Officer
2 Cronis 60 Mage
2 Ewoc 60 Warrior
2 Shortee 60 Rogue
2 Xirro 60 Druid
3 Agronom 60 Paladin
3 Benumbed 60 Priest Raid Leader
3 Souldat 60 Rogue
3 Warv 60 Paladin
That is the code I am copying & pasting into $pagetext form that I am runnin the top php code on to insert each name into the database. Right now, I am having to delete the spaces, numbers, class, leader, etc. and get it in:
Name
Name2
Name3
format. What I am asking is there a preg_strip to strip all from but names, then enter it in database. Sorry for not giving good details, its kinda hard for me to explain what it all this does =\
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.