Pulldown selection to form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rfigley
Forum Commoner
Posts: 70
Joined: Sun Apr 21, 2002 7:10 pm

Pulldown selection to form

Post by rfigley »

Inserting this pulldown menu script to provide selections from a database field in a form to submit to the database . However I need the result of the selection to be sumitted with the rest of the data in the form to the database. As it is, none of the other data is being submitted either.




<form action="new_entry2.php">
<table width="406" border="0">
<tr>
<td width="128"><b>Name:</b></td>
<td width="268">
<input type="text" name="name2" size="40" maxlength="40">
</td>
</tr>
<tr>
<td width="128"><b>Chapter:</b></td>
<td width="268">

Code: Select all

&lt;?
                 

 include('dbconnect.php');
 include('font_setting2.htm');

 $query = ("select * from tbl_chapter");

$result = mysql_query($query) or die("Query fail");

if (mysql_num_rows($result) == 0)
{

} else
{

   //echo "&lt;B&gt; Current Chapters List &lt;/B&gt;";
     echo  "&lt;select name='select'&gt;";

  while($row = mysql_fetch_array($result))
    {
        echo "&lt;option&gt;" . $row&#1111;'chapter_name'] . "&lt;/option&gt;";

           }

}                  
  ?&gt;
<tr>
<td width="128"><b>Category:</b></td>
<td width="268">
<input type="text" name="category2" size="40" maxlength="40">
</td>
</tr>
User avatar
gotDNS
Forum Contributor
Posts: 217
Joined: Tue May 07, 2002 5:53 pm
Location: West Chester, PA

Post by gotDNS »

Code: Select all

<option value='$option'>I'm an OPTION!</option>
set the value, and when u submit the form, it'll pass that in as the value for the variable that u names the SELECT.

ex.

Code: Select all

<select name='selectbox'>
<option value='a'>A</option>
<option value='b'>B</option>
</select>
Wherever that submits to: $selectbox = 'a' or 'b'

later on, -Brian
User avatar
gite_ashish
Forum Contributor
Posts: 118
Joined: Sat Aug 31, 2002 11:38 am
Location: India

Post by gite_ashish »

Hi,

What gotDNS says is absolutely correct, plus i would like to highlight & add something more to it.
As it is, none of the other data is being submitted either.

* If you are using PHP 4.2.x with default settings, there is difference in accessing the submitted <FORM>, Query String variables.
* This is also true even if you are using lower than PHP 4.2.x AND php.ini sets register_global=Off.
* The autoglobal/superglobal array names are different in both cases, actually depends upon the php version in use.

See the php man for the exact details, in case you have not visited yet:

http://www.php.net/manual/en/language.v ... efined.php


Regards,
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Post Reply