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





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help - Cant figure out why update not working when using dropdown box
#1
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
  Reply
#2
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?
  Reply
#3
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
  Reply
#4
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>

  Reply
#5
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...
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)