Jump to content

PHP Form


Mufleeh

Recommended Posts

Hi all,

 

I have used a dropdown menu inside the <form> tag. There are list of zones and one will be selected.

 

I would like to whether I can use PHP inside the <form></form> as I have used below and how to get the id of the selected one from the drop down men. Below is my code and it doesn't work as I expect, please advice.

 

 

                            <form method="post" id="graphDraw" action="<?php echo $_SERVER['SCRIPT_NAME']?>">

                                                       

                            <?php

                                                       

                            echo "<select name=\"".'zone_id'."_zone_".$zoneNo."\" style=\"width: 175px\">";

                                               

                            foreach($this->allZones as $zone)

                            {

                            echo "<option";

                            echo " value='$zone[zone_id]' ";

                            echo ">";

                            echo $zone['zone_id'].": ".$zone['zone_name'];

                            echo "</option>";

                            }

                            echo"</select>";

                            ?>

 

                            <input type="submit" value="Generate Graph"/>

                                                           

                            </form>

 

 

Once the button is clicked I need to get the id (zone_id) of the selected zone in the drop down menu and send it to a query.

 

 

Regards,

Mufleeh

Link to comment
Share on other sites

I'm not sure what $zoneNo contains, but let say you select tag looks like this:

 

 echo "<select name='zone_id' style=\"width: 175px\">";

 

 

In the code that processes the form submission, the zone_id can be retrieved with the following variable:

 

$_POST['zone_id']

 

 

Hi cyberRobot,

 

Thanks for your response! I made the it but there are problems in the queries if you could help me it would be really appriciated, http://www.phpfreaks.com/forums/index.php?topic=338495.0

 

Regards,

Mufleeh

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.