The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.28 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/printthread.php 16 require_once



UserSpice
Help - Cant figure out why update not working when using dropdown box - Printable Version

+- UserSpice (https://userspice.com/forums)
+-- Forum: Support Center (https://userspice.com/forums/forumdisplay.php?fid=23)
+--- Forum: UserSpice 4.3 and Below (https://userspice.com/forums/forumdisplay.php?fid=26)
+--- Thread: Help - Cant figure out why update not working when using dropdown box (/showthread.php?tid=538)



Help - Cant figure out why update not working when using dropdown box - muhammedc - 04-22-2017

Hi

Code: https://pastebin.com/PREbU7j3

I cant seem to figure out why the data in the dropdown boxes dont update the db if they are changed. Im sure im missing something and maybe just need a new pair of eyes... any ideas?

On a different note - Can we use validation class with drop down box data and when those items are changed, can we display the successes?

Thanks


Help - Cant figure out why update not working when using dropdown box - muhammedc - 04-23-2017

Ok - so... it does update the DB - but when you open the page again, it does not show the item which was updated as the selected item, instead it just sows the first item that is populated in the option list...

So at this code:

<label>Linked User Account:</label>
<select name="linkeduserid" class="form-control">
<?php
foreach ($permOps as $permOp){
echo "<option value='$permOp->id'>$permOp->email</option>";
}
?>
</select>

The above populates the available options from a database. What I would like is that we get the current value of the item from the db and have that as the selected item...

Any ideas?


Help - Cant figure out why update not working when using dropdown box - mudmin - 04-23-2017

So let's say that you have something in the settings table, column called "type". Just add that as a manual option above the foreach. Like this.

https://pastebin.com/37TkQtwX


Help - Cant figure out why update not working when using dropdown box - muhammedc - 04-23-2017

I manage to get the result changing the code to:

<select name="linkeduserid" class="form-control">
<?php
foreach ($permOps as $permOp){
if ($permOp->id == $companydetails->linkeduserid){
echo "<option value='$permOp->id' selected>$permOp->email</option>";;
}
else{
echo "<option value='$permOp->id'>$permOp->email</option>";
}
}
?>
</select>




Help - Cant figure out why update not working when using dropdown box - muhammedc - 04-23-2017

So...

Can we use validation class with drop down box data and when those items are changed, can we display the successes?

Like if you look at the admin_user.php file and in there, there is a select for yes or no to block the user. but when you choose an option there and update the data, it does not give you a success message on top of the page...