close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Update Multiple Rows with one form

Thread began 2/07/2018 6:26 am by anonymous | Last modified 3/20/2018 9:48 am by Ray Borduin | 4864 views | 63 replies |

anonymous

Update Multiple Rows with one form

I have a page that is laid out as a spreadsheet style and I want people to be able to edit multiple fields in multiple rows and it to update multiple rows at once when they submit the form. Here is the code I have so far.

<?php
$athlete = new WA_MySQLi_RS("athlete",$athletics2,0);
$athlete->setQuery("SELECT * FROM athlete_registrations left join athletes on athletes.athleteID = athlete_registrations.athleteID WHERE seasonID = ?");
$athlete->bindParam("i", "".(isset($_GET['seasonID']) ?$_GET['seasonID']:"") ."", "-1"); //colname
$athlete->execute();
?>

<?php
if (isset($_POST["Submit"]) || isset($_POST["Submit_x"])) {
$UpdateQuery = new WA_MySQLi_Query($athletics2);
$UpdateQuery->Action = "update";
$UpdateQuery->Table = "athlete_registrations";
$UpdateQuery->bindColumn("level4", "s", "".((isset($_POST["level4"]))?implode(",",$_POST["level4"]):"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("physical_date", "t", "".((isset($_POST["physical_date"]))?implode(",",$_POST["physical_date"]):"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("concussion_course2", "t", "".((isset($_POST["concussion_course2"]))?implode(",",$_POST["concussion_course2"]):"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("academic", "s", "".((isset($_POST["academic"]))?implode(",",$_POST["academic"]):"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("other_medical_info", "s", "".((isset($_POST["other_medical_info"]))?implode(",",$_POST["other_medical_info"]):"") ."", "WA_DEFAULT");
$UpdateQuery->addFilter("registrationID", "=", "i", "".($athlete->getColumnVal("registrationID")) ."");
$UpdateQuery->execute();
$UpdateGoTo = "edit_office_fields.php?seasonID=".$season->getColumnVal("seasonID") ."";

if (function_exists("rel2abs")) $UpdateGoTo = $UpdateGoTo?rel2abs($UpdateGoTo,dirname(__FILE__)):"";
$UpdateQuery->redirect($UpdateGoTo);
}
?>

I have tried to incorporate loops such as these and no luck:

{
foreach( $athlete as $key => $value) {

// end loop
}

I appreciate any help you can provide. Thanks

Sign in to reply to this post

Ray BorduinWebAssist

That should be possible if coded properly. I'd need you to attach the full page with the form and loops in place to comment on what you might have done wrong.

The ALPHA update has multiple update server behaviors that should make this easier if you want to give it a try:
http://www.webassist.com/forums/posts.php?pid=212123

Sign in to reply to this post
Did this help? Tips are appreciated...

anonymous

This is great. I downloaded it and when I try to apply the server behavior, it keeps saying that I need to have a repeat function applied to a form with form fields, which I do. Here is my table code:

<form method="post"><table width="100%" border="0" cellspacing="3" id="example" cellpadding="5" class="display">
<thead>
<tr>
<th height="39" valign="top">First Name</th>
<th valign="top">Last Name</th>
<th valign="top">Student ID#</th>
<th valign="top">Level</th>
<th valign="top">Physical Date</th>
<th valign="top">Concusion Course</th>
<th valign="top">Academic</th>
<th valign="top">Other Medical Info</th>
</tr>
</thead>
<tbody>
<?php
$wa_startindex = 0;
while(!$athlete->atEnd()) {
$wa_startindex = $athlete->Index;
?>
<tr>
<td valign="top"><?php echo($athlete->getColumnVal("student_fname")); ?></td>
<td valign="top"><?php echo($athlete->getColumnVal("student_lname")); ?></td>
<td valign="top"><?php echo($athlete->getColumnVal("studentID")); ?></td>
<td valign="top"><label for="level4"></label>
<select name="level4" id="level4">
<option value="" <?php if (!(strcmp("", ($athlete->getColumnVal("level4"))))) {echo "selected=\"selected\"";} ?>>Select One</option>
<option value="Varsity" <?php if (!(strcmp("Varsity", ($athlete->getColumnVal("level4"))))) {echo "selected=\"selected\"";} ?>>Varsity</option>
<option value="JV" <?php if (!(strcmp("JV", ($athlete->getColumnVal("level4"))))) {echo "selected=\"selected\"";} ?>>JV</option>
<option value="Freshman" <?php if (!(strcmp("Freshman", ($athlete->getColumnVal("level4"))))) {echo "selected=\"selected\"";} ?>>Freshman</option>
</select></td>
<td valign="top"><label for="physical_date"></label>
<input name="physical_date" type="text" id="datepicker" value="<?php echo(date("m/d/Y", strtotime($athlete->getColumnVal("physical_date")))); ?>"></td>
<td valign="top"><label for="concussion_course2"></label>
<input name="concussion_course2" type="text" id="datepicker2" value="<?php echo(date("m/d/Y", strtotime($athlete->getColumnVal("concussion_course2")))); ?>"></td>
<td valign="top"><label for="academic"></label>
<input name="academic" type="text" id="academic" value="<?php echo($athlete->getColumnVal("academic")); ?>" size="10">
<input name="registrationID" type="hidden" id="registrationID" value="<?php echo($athlete->getColumnVal("registrationID")); ?>"></td>
<td valign="top"><label for="other_medical_info"></label>
<textarea name="other_medical_info" id="other_medical_info" cols="30" rows="3"><?php echo($athlete->getColumnVal("other_medical_info")); ?></textarea></td>
</tr>
<?php
$athlete->moveNext();
}
if ($wa_startindex == $athlete->Index) $athlete->moveFirst(); //return RS to first record
unset($wa_startindex);
unset($wa_repeatcount);
?>
</tbody>
</table></form>

Thanks again for your help!

Sign in to reply to this post

Ray BorduinWebAssist

Remove the repeat region you have now and apply the repeat selection that is part of the BETA. I think the code is slightly different to support multiple updates.

Sign in to reply to this post
Did this help? Tips are appreciated...

anonymous

I did that. That is what is posted above. I still get the same error.

Sign in to reply to this post

Ray BorduinWebAssist

Is there any way I can get FTP access to the site so I can test on the page itself? If not, would you be interested in doing a screen sharing session so I can debug your page directly? I'd love the opportunity to investigate it and would be sure to at least get your pages working in the process free of charge.

Sign in to reply to this post
Did this help? Tips are appreciated...

anonymous

That would be great. We can setup a screen sharing if you would like. I am free anytime today. Thanks again for all your help.I really appreciate it.

Sign in to reply to this post

Ray BorduinWebAssist

Please post a US phone number or Skype contact information and I'll contact you for screen sharing.

Sign in to reply to this post
Did this help? Tips are appreciated...

anonymous

Number is below in private message :)

Sign in to reply to this post

anonymous

Hi Ray,

I just was trying to add the custom search form to a page and it won't let me hit the finish button at the end to add it. It is a dead link. Just wanted to let you know. Thanks

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...