How do you declare your select menu in the PHP?
Does it have to be an array of variables? One single variable?
Something else?
Let's say this one:

<select  name="search" title="Search Criteria">
      <option value="id">ID Status</option>
      <option value="ip">IP Status</option>
      <option value="pd">PD Status</option>
      <option value="nva">NVA Status</option>
</select>

Thank you!

First of what you gave got nothing to do with PHP, its a HTML select element. and what do you mean by declare.

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.

i.e. each case represents one of the options.

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.

i.e. each case represents one of the options.

Let's say I have this in my HTML form:

<select name="search" title="Search Criteria">
      <option value="id">ID Status</option>
      <option value="ip">IP Status</option>
      <option value="pd">PD Status</option>
      </select>

Here is my PHP:

<?php

$search = @$_POST['search'];
$id = @$_POST['id'];
$ip = @$_POST['ip'];
$pd = @$_POST['pd'];

?>

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[???]')";

Let's say I have this in my HTML form:

<select name="search" title="Search Criteria">
      <option value="id">ID Status</option>
      <option value="ip">IP Status</option>
      <option value="pd">PD Status</option>
      </select>

Here is my PHP:

<?php

$search = @$_POST['search'];
$id = @$_POST['id'];
$ip = @$_POST['ip'];
$pd = @$_POST['pd'];

?>

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; 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; 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!

Thank you so, so, so much!
It works perfectly well!

I am glad I could help! You should mark this thread solved so others can benefit from it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.