j.g. Posted August 27, 2007 Share Posted August 27, 2007 Hello All! I have a page that asks if the data input by the user should be visible or not -- if yes, it appears on the page, if no, don't show it. I was using a checkbox for this, but discovered that if the user tries to change it from checked to unchecked, it wasn't working correctly; so, I'm now trying a new dropdown function for this -- problem is, it's not saving the choice for each record now...and when you go in to update a record, the drop down is always blank vs. 'Yes' or 'No', depending on what the user selects... How can I fix this? Here's the call to the function in my form: <?= true_false_dropdown('visible', ($current->getVisible() == 1)); ?> And here's my function: // true / false dropdown function true_false_dropdown($name, $default="", $on_change="") { $tf = array ( "false" => "Yes", "true" => "No" ); return (array_dropdown($tf, $name, $default, true, $on_change)); } If anyone could tell me how to fix this, I'd be most appreciative. Thanks for your time and help! -j.g. Quote Link to comment https://forums.phpfreaks.com/topic/66916-newbie-need-help-w-function-change/ Share on other sites More sharing options...
Wuhtzu Posted August 27, 2007 Share Posted August 27, 2007 This code only shows the function and your function call and your problem seems to be database related - please show us some more code. Quote Link to comment https://forums.phpfreaks.com/topic/66916-newbie-need-help-w-function-change/#findComment-335498 Share on other sites More sharing options...
j.g. Posted August 27, 2007 Author Share Posted August 27, 2007 OK - thanks. Here's my code to Save it to the db: if ($_POST['save'] == 'Save') { $current->processPost($_POST); $current->setParent($parent_id); if ( (strlen($_FILES['FILE']['tmp_name']) > 0) && $_FILES['FILE']['error'] == 0) { $file = new File(); $file->readInFile($_FILES['FILE']['tmp_name'], $_FILES['FILE']['name'], $_FILES['FILE']['name']); $current->addFile($file); } header("Location: govt_relations_faq_updater.php?msg=".urlencode("'".$current->getTitle()."' Saved.")); exit; } My db col's/types pertaining to this: content_id - int(11) unsigned visible - tinyint(1) unsigned Is there any additional info that I'm missing that I could provide? If so, just let me know. Thanks! -j.g. Quote Link to comment https://forums.phpfreaks.com/topic/66916-newbie-need-help-w-function-change/#findComment-335507 Share on other sites More sharing options...
Wuhtzu Posted August 27, 2007 Share Posted August 27, 2007 The code you have posted helps little to resolve your problem... it looks like you use some kind of framework or at least some classes / function which we don't know of / about. Basically I have no idea about what your code does... it seems like it handles a file upload? Shouldn't it just write/update a single value in a specific row in your database... E.g. set the "Show private data" to "Yes" or "No" for a user? Quote Link to comment https://forums.phpfreaks.com/topic/66916-newbie-need-help-w-function-change/#findComment-335518 Share on other sites More sharing options...
j.g. Posted August 27, 2007 Author Share Posted August 27, 2007 Sorry. Everything is working (file uploads, save title, description, etc) except for the 'Visible' part... I cannot get the dropdown to work correctly. If you're on the page to enter data, the dropdown is visible, but blank - you can either select 'Yes' or 'No' from it -> but if I select 'No', then save it, and click 'Update' on the same record, all the info I've entered is there, but the dropdown is blank (Not saving the 'No'). And, the same with the 'Yes' --> and if it's set to 'Yes' I want to display it on another page, which I'll worry about after getting this issue resolved....I just want to get this backend stuff working first... I just first need to get this value to be saved and then able to switch the values (if 'Yes', change it to 'No', etc). What other information can I provide to help you help me? Thanks again! -j.g. Quote Link to comment https://forums.phpfreaks.com/topic/66916-newbie-need-help-w-function-change/#findComment-335528 Share on other sites More sharing options...
Wuhtzu Posted August 27, 2007 Share Posted August 27, 2007 So basically you would like your drop-down menu to remember what option the user is currently using? E.g. if the user has selected 'No' then you would like the drop-down menu to display / preselect 'No' the next time the user visits his profile editor? Quote Link to comment https://forums.phpfreaks.com/topic/66916-newbie-need-help-w-function-change/#findComment-335544 Share on other sites More sharing options...
j.g. Posted August 27, 2007 Author Share Posted August 27, 2007 Yes! -- I think I can use the function I created and posted w/ my initial post should work to accomplish this, but it's not... Quote Link to comment https://forums.phpfreaks.com/topic/66916-newbie-need-help-w-function-change/#findComment-335554 Share on other sites More sharing options...
Wuhtzu Posted August 27, 2007 Share Posted August 27, 2007 Of course you can change your function to "remember" the value... First of all you need to get the users setting and since this is stored in a database you need to run a query to find out whether the user has selected NO or YES. Then you have to tell your function to add the html attribute SELECTED to the option which the user has chosen. Quote Link to comment https://forums.phpfreaks.com/topic/66916-newbie-need-help-w-function-change/#findComment-335623 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.