/    Sign up×
Community /Pin to ProfileBookmark

Performing multip updates…

All,

I’ve got a form in which I’d like for viewer to be able to complete and then update them all at once. One of the form elements is a menu drop down, which complicates things. Here is how I’m trying to do it:

[code]
if ($_POST[‘save’] == “Save Position Changes”) {
$checked= $_POST[‘order’];
foreach ($checked as $action) {
update(“update articles set order = $action where id = ‘$action'”);
}
}

<select name=”order[]”>
<option value=”1″ <?php if (!(strcmp(1, $results[‘order’]))) {echo “selected=”selected””;} ?> id=”<?php echo $results[‘id’]; ?>”>1</option>
<option value=”2″ <?php if (!(strcmp(2, $results[‘order’]))) {echo “selected=”selected””;} ?> id=”<?php echo $results[‘id’]; ?>”>2</option>
<option value=”3″ <?php if (!(strcmp(3, $results[‘order’]))) {echo “selected=”selected””;} ?> id=”<?php echo $results[‘id’]; ?>”>3</option>
<option value=”4″ <?php if (!(strcmp(4, $results[‘order’]))) {echo “selected=”selected””;} ?> id=”<?php echo $results[‘id’]; ?>”>4</option>
<option value=”5″ <?php if (!(strcmp(5, $results[‘order’]))) {echo “selected=”selected””;} ?> id=”<?php echo $results[‘id’]; ?>”>5</option>
<option value=”6″ <?php if (!(strcmp(6, $results[‘order’]))) {echo “selected=”selected””;} ?> id=”<?php echo $results[‘id’]; ?>”>6</option>
</select>
[/code]

How can I pass both the value of the drop down and the id of the record?

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @cwilkey spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...