Not getting option value from my database...
Hello,
I am trying to get an option value from a database. I'm using the
following code snippet. This is a postgres 8.3.6 database. I am able
to use echo to get a list from the database. The code appears to
work, but later when I try to echo the id from the selected record, I
get no result. What I'm trying to do, is select the appropriate row
from the database using the options menu construct.
<form method="POST">
<?
echo "<p> Choose your prospect:
<select name='GetName'
size='". $rows ."'>";
while (list($peopleId, $fName, $mName, $lName,
$contactItem) = pg_fetch_row($SciName))
{
echo "<option value='".$peopleId."'> ". $fName . "
" . $mName . " " .$lName . " " . " ---". " " .
$contactItem . "</option>";
}
echo "</select>";
?>
<input type="submit" name="get_name" value="Submit" />
<input type="reset" value="Reset" /></p>
</form>
<?
}
}
if ($get_name == "Submit") { echo "People Id = " . $peopleId. "<br /
>"; }
Thank you for your time,
Carol Walter
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Not getting option value from my database...
--------------090806050502050508050702
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Can't say for sure where the problem is but seems to me that you're
using global variables instead of $_GET and $_POST. After sending the
form, you should access it's content using $_POST...
if (isset($_POST['get_name'])) {
echo "People Id = ".$_POST['GetName']."<br/>";
}
This should solve the problem of yours.
Carol Walter napsal(a):
> Hello,
>
> I am trying to get an option value from a database. I'm using the
> following code snippet. This is a postgres 8.3.6 database. I am able
> to use echo to get a list from the database. The code appears to
> work, but later when I try to echo the id from the selected record, I
> get no result. What I'm trying to do, is select the appropriate row
> from the database using the options menu construct.
>
> <form method="POST">
> <?
> echo "<p> Choose your prospect:
<select name='GetName' size='".
> $rows ."'>";
>
>
> while (list($peopleId, $fName, $mName, $lName,
> $contactItem) = pg_fetch_row($SciName))
> {
> echo "<option value='".$peopleId."'> ". $fName . " "
> . $mName . " " .$lName . " " . " ---". " " . $contactItem .
> "</option>";
> }
> echo "</select>";
> ?>
>
>
> <input type="submit" name="get_name" value="Submit" />
> <input type="reset" value="Reset" /></p>
> </form>
>
> <?
>
> }
>
> }
> if ($get_name == "Submit") { echo "People Id = " . $peopleId. "<br
> />"; }
>
> Thank you for your time,
>
> Carol Walter
>
--
S pozdravem
Daniel Tlach
Freelance webdeveloper
Email: mail [at] danaketh.com
ICQ: 160914875
MSN: danaketh [at] hotmail.com
Jabber: danaketh [at] jabbim.cz
--------------090806050502050508050702--