insert into vegetables values (1,'carot');
insert into vegetables values (2,'spinach');
insert into vegetables values (3,'potato');
insert into vegetables values (4,'tomato');
insert into vegetables values (5,'turnip');
create table veg_type (
type_id number(5));
here is my first php
page=====================================================
test insert
test insert into db
and here is my second php
page========================================================
$veg= $_POST['D1'];
$c1=oci_connect("stephane","Stef1975",$bdtest05);
// I have a question mark here because I don't know how to do it
$query="insert into veg_type (id_type) values (?)";
$stmt=oci_parse($c1,$query);
oci_execute($stmt);
oci_free_statement($stmt);
oci_close($c1);
?>
// thanks for looking!
//stephane
Re: please Help me out with this
am 17.03.2006 00:12:32 von zeldorblat
Steff wrote:
> Hello every one,
>
> I need your help because I have no idea how to do this...
>
> how can I get the veg_id into the table veg_type according to the vegetable
> name
> chosen in the pick list ?
>
> do I have to create another query in test2.php which select the veg_id
> from the vegetable table ?
>
> I would like to no what's best, I mean what's professional?
>
> I created those two tables for my test:
>
> create table vegetables (
> veg_id number(5),
> veg_name varchar2(30));
>
> insert into vegetables values (1,'carot');
> insert into vegetables values (2,'spinach');
> insert into vegetables values (3,'potato');
> insert into vegetables values (4,'tomato');
> insert into vegetables values (5,'turnip');
>
> create table veg_type (
> type_id number(5));
>
> here is my first php
> page=====================================================
>
>
>
>
>
> test insert
>
>
>
>
>
>
test insert into db
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> and here is my second php
> page========================================================
>
>
>
>
> $veg= $_POST['D1'];
>
>
> $c1=oci_connect("stephane","Stef1975",$bdtest05);
>
> // I have a question mark here because I don't know how to do it
>
> $query="insert into veg_type (id_type) values (?)";
>
> $stmt=oci_parse($c1,$query);
>
> oci_execute($stmt);
>
>
> oci_free_statement($stmt);
>
>
> oci_close($c1);
>
> ?>
>
> // thanks for looking!
>
> //stephane
Change
$query="select veg_name from vegetables";
to the following:
$query = "select veg_id, veg_name from vegetables";
Then, when building your select list, your option tag should look
something like this:
echo '';
So now the user will see veg_name ($row[1]) in the drop-down list, but,
when the form is submitted D1 will have the coresponding veg_id
($row[0]) as its value.