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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Programming ? 2

Status
Not open for further replies.

campyracr

IS-IT--Management
Jun 25, 2002
288
US
I am a few years removed from SQL programming and this one would have been beyond my means even then.

I am trying to create a database for an online petition.
One of the fields "they" want to be a Yes/No drop down list, such that users select either Yes/No and have no other options. I want SQL to capture the response with each entry in the other fields.

Any suggestions?
 
Unless you're going to give your users direct access to the data, you have a lot of choices for the database design.

It will be up to your user interface logic to handle storing the value in the column.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
my mistake. That was poorly worded.
We've looked at the needs again, and what is the path of least resistance.

The front end will be phrased in a Y or N format, and will put in a check box with the default value of the field =null.
 
campyracr
Are you happy with what sleipnir is saying - how you deal with Y/N or checkboxes is an issue of the programming environment you are going to use.

As regards MySQL you could store the data as eg BOOL/TINYINT or CHAR.

 
BNPMike,
Thanks. We are using PHP/MySQL I was didn't know how to write the syntax of such a drop down box, and have looked extensively at the PHP/SQL sites on the web. I don't assume I am the first to do this, so I am either not looking in the right places or, I've missed the answer all together.

The tip on data storage is greatly appreciated.
 
The html page...
Code:
<html><body>
<form name=myform action=check_test.php method=post>
checkbox<input type=checkbox name=myname value="yes">
<input type=submit name=submit value="submit">
</form>
</body></html>

//the php processing
Code:
<?php
//get the values from the form
$check = $_POST['myname'];
if ($check == ""){
  $check = "No";  //or 0 or N or whatever the desired param is
}else{
  $check = "Yes";
}
echo "check=$check"; //or 1 or Y as above

?>



Bastien

Cat, the other other white meat
 
okay its seems that I can't read and its much to early inthe morning for me...

lets try the html page again for a drop down instead of a checkbox
Code:
<html><body>
<form name=myform action=check_test.php method=post>
choose<select name=myname >
        <option value="yes">Yes
        <option value="no">No
      </select>
<input type=submit name=submit value="submit">
</form>
and the php only changes slightly
Code:
<?php
//get the values from the form
$check = $_POST['myname'];
if ($check == "No"){
  $check = "No";  //or 0 or N or whatever the desired param is
}else{
  $check = "Yes";
}
echo "check=$check"; //or 1 or Y as above
//insert into db code goes here
?>
</body></html>


Bastien

Cat, the other other white meat
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top