php - If one field empty, assign second to variable
Get the solution ↓↓↓I'm stuck with a very simple thing. I have two fields (maybe will be 3 later) on one page. Each field opens up by clicking radio button (other fields hide). I want to send field value to database, but i want all values to re-write one another, depending on what field is chosen. I have this code:
$get_amount_field = Tools::getValue('amount');
$get_value = Tools::getValue('formula');
if (isset($get_value)) {
$name_formatted = str_replace(' 2', '', $get_name);
$amount="UPDATE `pr_manufacturer` SET amount = '$get_value' WHERE name = '$name_formatted' ";
$get_amount = Db::getInstance()->execute($amount);
}
elseif (isset($get_amount_field)) {
$name_formatted = str_replace(' 2', '', $get_name);
$amount="UPDATE `pr_manufacturer` SET amount = '$get_amount_field' WHERE name = '$name_formatted' ";
$get_amount = Db::getInstance()->execute($amount);
}
but it saves only$get_value
value. If, for example,$get_value
value is none, and$get_amount_field
is 25 - after first submit button click database returns old$get_value
value, and after second submit with same value of$get_amount_field
- database column is just empty. What am I doing wrong perhaps?
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: you must enable the openssl extension in your php.ini to load information from https://repo.packagist.org
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.