f



PHP Question

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=====================================================

<html>

<head>

<title>test insert</title>

</head>

<body>

<p>test insert into db</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<form method="POST" action="test.php">

  <p><input type="text" name="vegy_name" size="20"><input type="submit" 
value="insert" name="B1"><input type="reset" value="reset" name="B2"></p>
</form>

<p>&nbsp;</p>

<form method="POST" action="test2.php">

  <p><select size="1" name="D1">
    <option selected>Vegy Name</option>

<?php

$c1=oci_connect("stephane","Stef1975",$bdtest05);

$query="select veg_name from vegetables";

$stmt=oci_parse($c1,$query);

oci_execute($stmt);

// here I get to chose what vegetable I want (it works fine)

while ($row = oci_fetch_array($stmt,OCI_NUM))
{
 print "<option>";
 echo $row[0];
 print "</option>";
}

oci_free_statement($stmt);

//close connexion
oci_close($c1);
?>

</select><input type="submit" value="insert" name="b3"><input type="reset" 
value="Reset" name="B4"></p>
</form>

</body>

</html>

and here is my second php 
page========================================================


<?php

$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 


0
Steff
3/16/2006 8:17:09 PM
comp.databases.oracle.tools 4963 articles. 0 followers. art (172) is leader. Post Follow

1 Replies
670 Views

Similar Articles

[PageSpeed] 10

Steff (stephane.vollet@bluewin.ch) wrote:
: Hello every one,

: I need your help because I have no idea how to do this...

It is really an html/php problem, nothing to do with oracle, but anyway


: <form method="POST" action="test2.php">

:   <p><select size="1" name="D1">
:     <option selected>Vegy Name</option>


<option value="the-id">the pretty name</option>

Note the VALUE option.  The user sees (and selects) "the pretty name" but
the value sent back is "the-id"

Also, check an upto date book on html because the "selected" by itself is 
old old html that should not be used.

0
yf110
3/16/2006 11:02:49 PM
Reply: