-1

I have created an HTML front-end. There is information in a locally stored database that I want to display in a drop down menu. In one menu, I would also like to add/enter information to be stored in the db.

Never used PHP before, but I know this is the route I need to take in order to accomplish my goal. Any tips on how to do this?

Thank you very much

2
  • This site is about getting help with specific programming questions. It is not designed to be a please provide with a working example kind of place. There are LOTS of example of how to do this all over the internet. Commented Oct 31, 2017 at 14:43
  • stackoverflow.com/questions/17342000/… This may be of some use... Commented Oct 31, 2017 at 14:53

1 Answer 1

0

Refer to this.

Should have answer you need. The person asking the question also used database to populate a drop down list.

Here's a code example (originally from here):

$server = 'servername';
$database = 'database_name';
$username = 'username';
$password = 'password';

mysql_connect($server,$username,$password);
mysql_select_db($database);
$result = mysql_query("SELECT column_name FROM your_cable")     or die(mysql_error());

if (mysql_num_rows($result)!=0)
{
echo '<select name="drop_2" id="drop_2">
      <option value=" " selected="selected">Choose one</option>';
       while($drop_2 = mysql_fetch_array( $result ))
        {
          echo '<option value="'.$drop_2['column_name'].'">'.$drop_2['column_name'].'</option>';
        }
echo '</select>';
Sign up to request clarification or add additional context in comments.

5 Comments

I was making a point that you can retrieve from the database and then populate the list.
Or are you asking more of 'how to retrieve from the database'?
Check this site then.
No. You'll need to change mysql_connect and mysql_select_db to mssql_connect, etc. Check manual Should be easy to do! Good luck.
So you copied and pasted an answer from a 6 year old post on another site that isn't even using the same type of database. This is not helpful. The question is too broad to be useful, and answering it just clutters the site up.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.