Page 1 of 1

Pulldown selection to form

Posted: Sun Sep 01, 2002 11:17 pm
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>

Posted: Mon Sep 02, 2002 12:29 am
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

Posted: Mon Sep 02, 2002 8:47 am
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,

Posted: Mon Sep 02, 2002 9:15 am
by twigletmac