Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Forms

Status
Not open for further replies.

cogdev

MIS
Joined
Nov 30, 2001
Messages
85
Location
US
I am new to PHP. I am doing a select (select subject from tbl_subjects_taken)from a table, and displaying the results in a drop-down menu. How do I display the one subject selected fom the drop-down list and how can I use that as a prompt parameter for another query?
 
Well, I'll start out by assuming your form type is "post" and that you're "posting" to a page named "submit.php".

All values entered in a form are stored in the $HTTP_POST_VARS[] array or the $HTTP_GET_VARS[] array, depending on how you're sending the form data.

So, if form.php looks like this:

Code:
<html>
<head><title>form page</title></head>
<body>
<form action="submit.php" method="post">
Select Subject:
<select name="subject">
<option value="math">Math</option>
<option value="science">Science</option>
<option value="english">English</option>
</select>
<input type="submit">
</form>
</body>
</html>

And submit.php looks like this:

Code:
<?php
$subject = $HTTP_POST_VARS['subject'];
?>

<html>
<head><title>submit page</title></head>
<body>
You have selected <? echo $subject; ?>.
</body>
</html>

Will display "You have selected science." if you selected science.

*cLFlaVA
----------------------------
A polar bear walks into a bar and says, "Can I have a ... beer?"
The bartender asks, "What's with the big pause?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top