trynalearn
trynalearn

Reputation: 1

would like some help related to php drop down form

and thanks in advance for looking, your time and your help.

I am currently trying to create a drop down menu list.

it involves shiping types for example , Royal mail, DHL ect.

however i am getting no where.

i have my data base set like below

field   | type         | collation         | null | extra
post_id | bigint(20)   |                   | no   | auto_increment
type    | varchar(255) | latin_1swedish_ci | no   |

the name of this in my database is called postage_type.

i have populated that tag. inside it,

royal mail  (1)
DHL (2)

ect.

would it be possible for someone to share how to create a drop down form and then how to receive the data.

+

i believe i will need a $_GET due to my pages using as such shipping_detail.php?=item2290 etc,

the page i would like the drop down box on is called "shipping_detail.php" and i would like the chosen menu option to be placed on a page called "detail.php"

thanks for looking and i hope i made this clear enough.

i have read more than a few tutorials however i am completely confused by them.

Upvotes: 0

Views: 137

Answers (2)

Jack Billy
Jack Billy

Reputation: 7211

This is just a piece of cake. You only have to do is to use the include function of PHP. Just like below.

SOLUTION CODE

<select name="your-drop-down-list-name">
         <?php include('path-to-you-file-dir/shipping_detail.php'); ?>
</select>

Upvotes: 0

korona
korona

Reputation: 2229

I won't give you a complete answer, since your question isn't narrow and specific enough for that. But here are the things you need to do:

  1. Build the page that has the form in HTML. This requires no knowledge of PHP.
  2. Make sure the form will submit data to your PHP script.
  3. In your PHP script, receive the data and handle it accordingly

Here's some short example code:

The page where your dropdown is needs to have code similar to this:

<form method="GET" action="handleform.php">
    <label for="shipping_method">Shipping method</label>
    <select name="shipping_method" id="shipping_method">
        <option value="dhl">DHL</option>
        <option value="royalmail">Royal Mail</option>
    </select>
    <input type="submit"/>
</form>

And then in handleform.php:

$shipping_method = $_GET['shipping_method'];
// and then do whatever you need to do with this value, probably store it in a database

Honestly though, your question is a little too open ended to give a straight up answer to, since there are so many implementation specific details left out.

Upvotes: 1

Related Questions