close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Lookup both session userid and database value then using update record

Thread began 9/24/2020 3:31 am by Jonas | Last modified 9/24/2020 4:34 pm by Ray Borduin | 14 views | 2 replies |

Jonas

Lookup both session userid and database value then using update record

I want only the record with id (myl_bucID) to be updated that has the same user who is logged in.

I do not know how to merge two lookup values.

It works in part if I only use id (see 1 below). But then every post with this id is updated, and with every user. Now I only want this ID to be updated that has the same user who is logged in.

I have two different lookup codes that I want to merge, I think:
1) $UpdateQuery->addFilter("myl_bucID", "=", "d", "".((isset($_POST["buc_id"]))?$_POST["buc_id"]:"") ."");
2) $UpdateQuery->addFilter("myl_bucID", "=", "d", "".$_SESSION['SecurityAssist_UserID'] ."");

Heres the update record code:
<?php
if (isset($_POST["doneRegister"]) || isset($_POST["doneRegister_x"])) {
$UpdateQuery = new WA_MySQLi_Query($bucketListHub);
$UpdateQuery->Action = "update";
$UpdateQuery->Table = "bucMylist";
$UpdateQuery->bindColumn("myl_done", "i", "".((isset($_POST["bucketDone"]))?$_POST["bucketDone"]:"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("myl_doneDate", "t", "".((isset($_POST["bucketDoneDate"]))?$_POST["bucketDoneDate"]:"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("myl_dateUpdate", "t", "", "WA_CURRENT_TIMESTAMP");
$UpdateQuery->addFilter("myl_bucID", "=", "d", "".((isset($_POST["buc_id"]))?$_POST["buc_id"]:"") ."");
$UpdateQuery->execute();
$UpdateGoTo = "";
if (function_exists("rel2abs")) $UpdateGoTo = $UpdateGoTo?rel2abs($UpdateGoTo,dirname(__FILE__)):"";
$UpdateQuery->redirect($UpdateGoTo);
}
?>

Sign in to reply to this post

Ray BorduinWebAssist

You can just add another addFilter line manually like you have referenced... but I think your column name is wrong. I think it should be something like:


php:
<?php

if (isset($_POST["doneRegister"]) || isset($_POST["doneRegister_x"])) {
$UpdateQuery = new WA_MySQLi_Query($bucketListHub);
$UpdateQuery->Action "update";
$UpdateQuery->Table "bucMylist";
$UpdateQuery->bindColumn("myl_done""i""".((isset($_POST["bucketDone"]))?$_POST["bucketDone"]:"") ."""WA_DEFAULT");
$UpdateQuery->bindColumn("myl_doneDate""t""".((isset($_POST["bucketDoneDate"]))?$_POST["bucketDoneDate"]:"") ."""WA_DEFAULT");
$UpdateQuery->bindColumn("myl_dateUpdate""t""""WA_CURRENT_TIMESTAMP");
$UpdateQuery->addFilter("myl_bucID""=""d""".((isset($_POST["buc_id"]))?$_POST["buc_id"]:"") ."");
$UpdateQuery->addFilter("myl_UserID""=""d""".($_SESSION['SecurityAssist_UserID']) ."");
$UpdateQuery->execute();
$UpdateGoTo "";
if (
function_exists("rel2abs")) $UpdateGoTo $UpdateGoTo?rel2abs($UpdateGoTo,dirname(__FILE__)):"";
$UpdateQuery->redirect($UpdateGoTo);
}
?>



I don't know the correct column name, so I used myl_UserID in my example... but I'm pretty sure the two filters wouldn't be set to the same column since it couldn't have two values simultaneously.

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

Jonas

Thumbs up, Thanks!

Sign in to reply to this post

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...