1 Replies - 1037 Views - Last Post: 27 September 2011 - 06:09 PM Rate Topic: -----

#1 dbeaird727  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 238
  • Joined: 13-December 10

Submit query to the database?

Posted 27 September 2011 - 04:45 PM

I have this code to create a drop down menu (selectbox)...

               <?php
               $query = "SELECT name FROM table";
               $result = mysql_query($query) or die(mysql_error());

               $dropdown = "<select name='table'>";
                  while($row = mysql_fetch_assoc($result)) {
                     $dropdown .= "\r\n<option value='{$row['name']}'>{$row['name']}</option>";
                  }
                     $dropdown .= "\r\n</select>";
                       echo $dropdown;
               ?>


How do I actually submit the query to the database to pull the actual name from the table? Would i create an external script and "include" it? or can I simply add an "input" button to this code to actually select that option?

And also.. How would I keep these options selected for later logins? Would I use

session_start()
and then $_SESSION['name'];

Is This A Good Question/Topic? 0
  • +

Replies To: Submit query to the database?

#2 codeprada  Icon User is offline

  • Changed Man With Different Priorities
  • member icon

Reputation: 947
  • View blog
  • Posts: 2,355
  • Joined: 15-February 11

Re: Submit query to the database?

Posted 27 September 2011 - 06:09 PM

Have a look here.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1