Re: Problem with INSERT Query
| From: | Hadi | Date: | Tue, 30 Dec 2003 15:55:37 +0000 |
| Subject: | Re: Problem with INSERT Query | ||
| References: | 1 | Groups: | php.db php.general |
| Request: | Send a blank email to php-db+get-32221@lists.php.net to get a copy of this message | ||
<irinchiang@justeducation.com> wrote in message
news:1072768171.3ff124abe14e8@www.justeducation.com...
>
>
> Hi all:
>
> Well, when i bring out the page with the drop down list it was able to
display
> all tutors' names from "tutor_name" column. Anyway here's a review of my
code
> (snip) again before i continue:
> --------------------------------------------------------------------------
-----
> <snip>
> $sql = "INSERT INTO class (class_code, tutor_name, edu_level,
timetable_day,
> timetable_time)
> VALUES
>
('$class_code','$tutor_name','$edu_level','$timetable_day','$timetable_time'
)";
>
>
> <?//retrieve data from DB & display in dynamic drop down ?>
>
> <SELECT class="textarea" name="tutor_name" />
> <?
>
>
$sqltutor = mysql_query("SELECT DISTINCT tutor_name FROM tutor ");
while ($row = mysql_fetch_array($sqltutor))
{
print "<OPTION VALUE=\"$row ["tutor_name"]. \" SELECTED> "
.$row
["tutor_name"]. "</option> ";
> }
> $result = $db-> query($sql);
>
> ?>
> </select>
>
> <?
>
> while($selected_tutor_name == $tutor_name)
> echo $_POST["tutor_name"];
>
How about
if ($tutor_name ){
echo $_POST["tutor_name"];
$sql = "INSERT INTO class (class_code, tutor_name, edu_level, timetable_day,
timetable_time)
VALUES
('$class_code','$tutor_name','$edu_level','$timetable_day','$timetable_time'
)";}
is it working?
Hadi
> ?>
>
> </snip>
>
> --------------------------------------------------------------------------
-----
>
> so when i submit the form, i am suppose to echo the values i have entered
into
> the field and then INSERT the values into DB (Queries stated above).
However i
> was able to echo all other values eg. class_code, edu_level, etc...but
> not "tutor_name"....same thing happen when i do an INSERT, all other
values
> are inserted into DB but not $tutor_name....why is this so???Really need
some
> help here...Anyway i have already specify a name to be reference :
>
> <SELECT class="textarea" name="tutor_name" >
>
> and then I also did an echo of "tutor_name" being selected:
>
> while($selected_tutor_name == $tutor_name)
> echo $_POST["tutor_name"];
>
> All help are greatly appreciated =)
>
> Irin.