hi...
Does anyine can help me, iwant to create combo box on php form, but the it value from table content.
this is my table
table name: country
id---country
1---USA
2---England
3---China
4---Japan
etc..
i'm use Postgre DB
hi...
Does anyine can help me, iwant to create combo box on php form, but the it value from table content.
this is my table
table name: country
id---country
1---USA
2---England
3---China
4---Japan
etc..
i'm use Postgre DB
I'm sorry, but I don't quite understand your question.
<select name="variablename">
<option value="value">displayedname
<option value="value2">displayedname2
</select>
That will give you a drop down menu.
Then, with php, depending on "get" or "post" method in your form tag (<form method="get">), you can use:
$_GET['variablename'] or $_POST['variablename'] to use those sent values.
Is this close?
Can you please link to the page you are having trouble with? It's a bit hard to understand what you want.
Code:<select multiple="true"> <?php $dbuser = "your user"; $dbpass = "your password"; $dbname = "the name of the database"; $tablename = "the name of the table"; $conn = pg_connect("host=localhost port=5432 dbname=$dbname user=$dbuser pass=$dbpass"); $query = "SELECT * FROM $tablename;"; $rs = pg_query($query, $conn); while($row = pg_fetch_array($rs)) { ?> <option value="<?php echo($row['id']); ?>"><?php echo($row['country']); ?></option> <?php } ?> </select>
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Bookmarks