That would be great thanks =] I'll try and figure it out tho.
--------------- Added [DATE]1313870349[/DATE] at [TIME]1313870349[/TIME] ---------------
Ok.. got somewhere.
I have my fields named as: gender[{vb:raw id}], free[{vb:raw id}], active[{vb:raw id}]
and my inputs being validated:
PHP Code:
$vbulletin->input->clean_array_gpc('p', array(
'gender' => TYPE_ARRAY_UINT,
'free' => TYPE_ARRAY_UINT,
'active' => TYPE_ARRAY_UINT,
));
Now it's figuring out how to post the data to the database. I've had a look at the foreach, but I think that'd require foreach loops for each array?
PHP Code:
$i = 1; /* for illustrative purposes only */
foreach ($vbulletin->GPC['gender'] as $gender) {
echo "\$vbulletin->GPC['gender'][$i] => $gender.\n";
$i++;
}
Which outputs:
Code:
$vbulletin->GPC['gender'][1] => 3. $vbulletin->GPC['gender'][2] => 3. $vbulletin->GPC['gender'][3] => 3.
Is there a way to merge them together or another way of doing it?
--------------- Added [DATE]1313874927[/DATE] at [TIME]1313874927[/TIME] ---------------
Got it working! Thanks for your help Marco.
So, you don't need multiple foreach loops, you just put your array in the first one. Here's the full working code if anyone's interested:
PHP Code:
if($_REQUEST['action'] == "updatenames")
{
// Clean parameters
$vbulletin->input->clean_array_gpc('p', array(
'gender' => TYPE_ARRAY_UINT,
'free' => TYPE_ARRAY_UINT,
'active' => TYPE_ARRAY_UINT,
));
// Get the oldest ID
$oldestID = $db->query_first("SELECT id FROM " . TABLE_PREFIX . "names WHERE userid = '" . $vbulletin->userinfo['userid'] . "' ORDER BY id ASC");
$i = $oldestID['id'];
// Loop through and update each record
foreach ($vbulletin->GPC['gender'] as $gender)
{
// Easy names
$free = $vbulletin->GPC['free'][$i];
$active = $vbulletin->GPC['active'][$i];
$db->query_write("
UPDATE " . TABLE_PREFIX . "names
SET gender = '$gender',
free = '$free',
active = '$active'
WHERE id = '$i'
");
$i++;
}
// Redirect to view changes
$vbulletin->url="names.php?" . $vbulletin->session->vars['sessionurl'] . "do=viewnames";
eval(print_standard_redirect('names_updated', true, true));
}