close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

update multiple records with a checkbox

Thread began 1/23/2020 9:21 am by JBWebWorks | Last modified 1/30/2020 9:48 pm by Ray Borduin | 3397 views | 22 replies |

JBWebWorks

update multiple records with a checkbox

I have a page with multiple records from orders placed and a checkbox where the owner reviews the orders, and checks the box to record that she has reviewed a particular order.
In the update multiple records behavior, i'm not sure what value to give the checked box. Currently I have just the value for just the checkbox itself.
I get this error when I try to update.
Fatal error: Uncaught Error: Call to undefined function WA_AB_getLoopedFieldValue() in /home/l4onkda599e9/public_html/orders-for-excel.php:39 Stack trace: #0 {main} thrown in /home/l4onkda599e9/public_html/orders-for-excel.php on line 39

code for the form

<?php /*START_PHP_SIRFCIT*/ if ($rs_ordersinfo->getColumnVal('OrderID')==""){ ?>
<span class="stylered">No records matched your search</span>
<?php } /*END_PHP_SIRFCIT*/ ?>
<form action="" method="post" enctype="multipart/form-data" name="form2" id="form2">
<table width="100%" border="1" cellpadding="5" id="orderinfo">
<tr bgcolor="#0099FF">
<td id="1" width="9%">TOUR</td>
<td id="2" width="9%">NAME</td>
<td id="3" width="6%">ORDER DATE</td>
<td id="4" width="4%">QTY</td>
<td id="5" width="12%">TENT</td>
<td id="6" width="3%">STD AIR MATTRESS</td>
<td id="7" width="3%">DBL AIR MATTRESS</td>
<td id="8" width="3%">QUEEN AIR MATTRESS</td>
<td id="9" width="3%">COFFEE</td>
<td id="10" width="3%">CHAIR</td>
<td id="11" width="3%">TOWEL</td>
<td id="12" width="12%">REQUEST</td>
<td id="13" width="8%">FROM EMAIL</td>
<td id="14" width="4%">GROSS</td>
<td id="15" width="4%">FEE</td>
<td id="16" width="4%">NET</td>
<td id="17" width="4%">PAID BY</td>
<td id="18" width="3%">SHAWN</td>
<td id="19" width="3%" style="display:none">BECKY</td>
</tr>
<?php
$wa_startindex = 0;
while(!$rs_ordersinfo->atEnd()) {
$wa_startindex = $rs_ordersinfo->Index;
?>
<tr>
<td><?php echo $rs_ordersinfo->getColumnVal('DetailItemDesc'); ?></td>
<td><?php echo $rs_ordersinfo->getColumnVal('BuyerLastName'); ?>, <?php echo $rs_ordersinfo->getColumnVal('BuyerFirstName'); ?></td>
<td><?php echo $rs_ordersinfo->getColumnVal('OrderDate'); ?></td>
<td><?php echo $rs_ordersinfo->getColumnVal('DetailQuantity'); ?></td>
<td><?php echo $rs_ordersinfo->getColumnVal('DetailItemName'); ?></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><?php echo $rs_ordersinfo->getColumnVal('requests'); ?></td>
<td><?php echo $rs_ordersinfo->getColumnVal('Buyeremail'); ?></td>
<td>$ <?php echo number_format($rs_ordersinfo->getColumnVal('OrderTotal'), 2); ?></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><?php echo $rs_ordersinfo->getColumnVal('paid_by'); ?></td>
<td><input type="hidden" name="Shawn_wamultihidden[]" id="Shawn_wamultihidden_<?php echo $wa_repeatcount; ?>_<?php echo($wa_startindex); ?>" value="1" />
<input name="Shawn_<?php echo $wa_repeatcount; ?>_<?php echo($wa_startindex); ?>" type="checkbox" id="Shawn_<?php echo $wa_repeatcount; ?>_<?php echo($wa_startindex); ?>" value="1" <?php if (!(strcmp($rs_ordersinfo->getColumnVal('shawn'),1))) {echo "checked=\"checked\"";} ?> />
<input type="hidden" name="WADA_RepeatID_DetailsID[]" id="WADA_RepeatID_DetailsID_<?php echo($wa_startindex); ?>" value="<?php echo($wa_startindex); ?>" /></td>
<td style="display:none"><input name="Becky_<?php echo $wa_repeatcount; ?>_<?php echo($wa_startindex); ?>" type="checkbox" id="Becky_<?php echo $wa_repeatcount; ?>_<?php echo($wa_startindex); ?>" value="1" <?php if (!(strcmp($rs_ordersinfo->getColumnVal('becky'),1))) {echo "checked=\"checked\"";} ?> /></td>
</tr><?php
$rs_ordersinfo->moveNext();
}
$rs_ordersinfo->moveFirst(); //return RS to first record
unset($wa_startindex);
unset($wa_repeatcount);
?>
</table>

<input type="submit" name="Submit1" id="Submit1" value="Update Checkbox Information" />

</form>



code for the recordset and mysqli UPDATE

<?php 
error_reporting(E_ALL);
ini_set('display_errors',on);
?><?php require_once('Connections/conncomfysqli.php'); ?>
<?php require_once( "webassist/security_assist/helper_php.php" ); ?>
<?php require_once('webassist/mysqli/rsobj.php'); ?>
<?php require_once('webassist/mysqli/queryobj.php'); ?>
<?php
if (!WA_Auth_RulePasses("Logged in to admin")){
WA_Auth_RestrictAccess("admin_login.php");
}
?>
<?php require_once("webassist/database_management/wada_search.php"); ?>
<?php
$searchrs_ordersinfo_1 = new WA_MySQLi_Search("rs_ordersinfo","");
if ($_SERVER["REQUEST_METHOD"] === "POST") {
$searchrs_ordersinfo_1->clearSearch();
$searchrs_ordersinfo_1->setSearch(array("type"=>"Value", "comparison"=>"=", "join"=>"AND"), array("DetailItemID"), "s", "".((isset($_POST["tour1"]))?$_POST["tour1"]:"") ."");
$searchrs_ordersinfo_1->setSearch(array("type"=>"Value", "comparison"=>"Includes", "join"=>"AND"), array("BuyerLastName"), "s", "".((isset($_POST["name1"]))?$_POST["name1"]:"") ."");
$searchrs_ordersinfo_1->setSearch(array("type"=>"Value", "comparison"=>"Includes", "join"=>"AND"), array("BuyerFirstName"), "s", "".((isset($_POST["name2"]))?$_POST["name2"]:"") ."");
$searchrs_ordersinfo_1->setSearch(array("type"=>"Value", "comparison"=>"Includes", "join"=>"AND"), array("DetailItemName"), "s", "".((isset($_POST["tentpkg1"]))?$_POST["tentpkg1"]:"") ."");
$searchrs_ordersinfo_1->setSearch(array("type"=>"Value", "comparison"=>">=", "join"=>"AND"), array("OrderDate"), "t", "".((isset($_POST["date1"]))?$_POST["date1"]:"") ."");
}
?>
<?php
if (isset($_POST["Submit1"]) || isset($_POST["Submit1_x"])) {
$MultipleUpdateConnection = $conncomfysqli;
$MultipleUpdateTable = "orderdetails";
$MultipleUpdateRedirect = "admin.php";
$MultipleUpdateIndexColumn = "DetailsID";
$MultipleUpdateIndexColumnType = "d";
$MultipleUpdateIdentifier = "WADA_RepeatID_DetailsID";
$MultipleUpdateArray = isset($_POST[$MultipleUpdateIdentifier])?$_POST[$MultipleUpdateIdentifier]:array();
for ($mu=0; $mu<sizeof($MultipleUpdateArray); $mu++) {
$MultipleUpdateCount = $MultipleUpdateArray[$mu];
$UpdateQuery = new WA_MySQLi_Query($MultipleUpdateConnection);
$UpdateQuery->Action = "update";
$UpdateQuery->Table = $MultipleUpdateTable;
$UpdateQuery->bindColumn("shawn", "c", "".WA_AB_getLoopedFieldValue("Shawn_".$wa_repeatcount ."", $WA_multipleUpdateCounter) ."?php echo $wa_repeatcount; ?>", "WA_IGNORE");
$UpdateQuery->addFilter($MultipleUpdateIndexColumn, "=", $MultipleUpdateIndexColumnType, $_POST[$MultipleUpdateIdentifier."_".$MultipleUpdateCount]);
$UpdateQuery->execute();
}
if ($MultipleUpdateRedirect) {
if (function_exists("rel2abs")) $MultipleUpdateRedirect = rel2abs($MultipleUpdateRedirect,dirname(__FILE__));
header("location: " . $MultipleUpdateRedirect);
}
}
?>
<?php
$rs_ordersinfo = new WA_MySQLi_RS("rs_ordersinfo",$conncomfysqli,0);
$rs_ordersinfo->setQuery("SELECT * FROM orders JOIN orderdetails ON orders.OrderID = orderdetails.DetailOrderID ORDER BY orders.OrderDate DESC");
$rs_ordersinfo->execute();
?>
Sign in to reply to this post

Ray BorduinWebAssist

I think this line:
$UpdateQuery->bindColumn("shawn", "c", "".WA_AB_getLoopedFieldValue("Shawn_".$wa_repeatcount ."", $WA_multipleUpdateCounter) ."?php echo $wa_repeatcount; ?>", "WA_IGNORE");

should be:
$UpdateQuery->bindColumn("shawn", "c", "".($_POST["Shawn_".$MultipleUpdateCount]) ."", "WA_IGNORE");

It looks like it wasn't properly changed when you updated from MySQL to MySQLi

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

JBWebWorks

made that change to this

$UpdateQuery->bindColumn("shawn", "c", "".($_POST["Shawn_".$MultipleUpdateCount]) ."", "WA_IGNORE");
$UpdateQuery->addFilter($MultipleUpdateIndexColumn, "=", $MultipleUpdateIndexColumnType, $_POST[$MultipleUpdateIdentifier."_".$MultipleUpdateCount]);
$UpdateQuery->execute();



now get this error
Notice: Undefined index: Shawn_0 in /home/l4onkda599e9/public_html/orders-for-excel.php on line 39

Notice: Undefined index: WADA_RepeatID_DetailsID_0 in /home/l4onkda599e9/public_html/orders-for-excel.php on line 40
There is an error in your SQL syntax.

Sign in to reply to this post

Ray BorduinWebAssist

I see another issue.... do a find and replace to find:

php:
_<?php echo $wa_repeatcount?>_<?php echo($wa_startindex); ?>



and replace it with:

php:
_<?php echo($wa_startindex); ?>
Sign in to reply to this post
Did this help? Tips are appreciated...

JBWebWorks

get these errors
Notice: Undefined index: Shawn_0 in /home/l4onkda599e9/public_html/orders-for-excel.php on line 39

Notice: Undefined index: WADA_RepeatID_DetailsID_0 in /home/l4onkda599e9/public_html/orders-for-excel.php on line 40
There is an error in your SQL syntax.

Sign in to reply to this post

Ray BorduinWebAssist

Please attach a current copy of the page.

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

JBWebWorks

attached

Attached Files
orders-for-excel.php
Sign in to reply to this post

Ray BorduinWebAssist

I didn't realize it was a checkbox. This code:

$UpdateQuery->bindColumn("shawn", "c", "".($_POST["Shawn_".$MultipleUpdateCount]) ."", "WA_IGNORE");



Should be:

$UpdateQuery->bindColumn("shawn", "c", "".(isset($_POST["Shawn_".$MultipleUpdateCount])?"1":"0") ."", "WA_IGNORE");
$UpdateQuery->bindColumn("becky", "c", "".(isset($_POST["Becky_".$MultipleUpdateCount])?"1":"0") ."", "WA_IGNORE");
Sign in to reply to this post
Did this help? Tips are appreciated...

JBWebWorks

I get this error now
Notice: Undefined index: WADA_RepeatID_DetailsID_0 in /home/l4onkda599e9/public_html/orders-for-excel.php on line 40
There is an error in your SQL syntax.

This is the line
$UpdateQuery->addFilter($MultipleUpdateIndexColumn, "=", $MultipleUpdateIndexColumnType, $_POST[$MultipleUpdateIdentifier."_".$MultipleUpdateCount]);
$UpdateQuery->execute();

Sign in to reply to this post

Ray BorduinWebAssist

Update this:

php:
$UpdateQuery->addFilter($MultipleUpdateIndexColumn, "=", $MultipleUpdateIndexColumnType, $_POST[$MultipleUpdateIdentifier."_".$MultipleUpdateCount]);



to this:

php:
$UpdateQuery->addFilter($MultipleUpdateIndexColumn, "=", $MultipleUpdateIndexColumnType, $_POST["Shawn_wamultihidden_".$MultipleUpdateCount]);



and update this:

php:
<input type="hidden" name="Shawn_wamultihidden[]" id="Shawn_wamultihidden_<?php echo($wa_startindex); ?>" value="1" />



to this:

php:
<input type="hidden" name="Shawn_wamultihidden_<?php echo($wa_startindex); ?>" id="Shawn_wamultihidden_<?php echo($wa_startindex); ?>" value="<?php echo($rs_ordersinfo->getColumnVal('DetailID')); ?>" />
Sign in to reply to this post
Did this help? Tips are appreciated...
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...