First of what you gave got nothing to do with PHP, its a HTML select element. and what do you mean by declare.
Yes, I know.
What I mean is I need to write an IF... ELSE statement in PHP using data from the select menu that comes from my HTML form.
Can't figure out how this should be done.
Yes, I know.
What I mean is I need to write an IF... ELSE statement in PHP using data from the select menu that comes from my HTML form.
Can't figure out how this should be done.
Still you not describing, what exactly you expect from the PHP, even though this is a proper English than your first post.
I assume you have some html form and in another page you putting those inputs in the select ekement.
For example in your first html form you ask the user to input his qualification etc.He enters Xth,XIIth, Grad and Post-grad details and then next form carries the data and displayed in the select element.
If I am wrong correct me.
Simply, if I understand what you want to do, you should have a value for each option in your HTML select element of your form. Then, in php, you should have variables which grab those option values (with $_POST or $_GET depending on your form), and then feed them into a switch statement (better than IF statement for this purpose I believe) and put inside each case of your switch what you want it to do for each option.
Simply, if I understand what you want to do, you should have a value for each option in your HTML select element of your form. Then, in php, you should have variables which grab those option values (with $_POST or $_GET depending on your form), and then feed them into a switch statement (better than IF statement for this purpose I believe) and put inside each case of your switch what you want it to do for each option.
Is that correct?
What if I need to grab a value from my HTML select element (one of the options) and send it to a database?
What do I write in my INSERT statement?
Is that correct?
What if I need to grab a value from my HTML select element (one of the options) and send it to a database?
What do I write in my INSERT statement?
$sql = "insert into mytable (status) values ('$_POST[???]')";
No this is not correct. You only need $search = @$_POST['search']; in order to capture the selection. Then in your switch statement you should say that if the $search is equal to id, then do this, and so on.
Then, in your db query you should command something like
$sql = "INSERT INTO `mytable` (status) VALUES ($search);"
IMPORTANT NOTE: The SQL query should go into EVERY single on of your case statements of the switch. I hope you get what I mean... Try it out and report back any problems.
No this is not correct. You only need $search = @$_POST['search']; in order to capture the selection. Then in your switch statement you should say that if the $search is equal to id, then do this, and so on.
Then, in your db query you should command something like
$sql = "INSERT INTO `mytable` (status) VALUES ($search);"
IMPORTANT NOTE: The SQL query should go into EVERY single on of your case statements of the switch. I hope you get what I mean... Try it out and report back any problems.
Thank you so, so, so much!
It works perfectly well!
Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.
This thread is more than three months old
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.