Advertisement
Guest User

Untitled

a guest
Mar 7th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. <?
  2. $dbHost = 'localhost'; // localhost will be used in most cases
  3. // set these to your mysql database username and password.
  4. $dbUser = 'user';
  5. $dbPass = 'pass';
  6. $dbDatabase = 'stock'; // the database you put the table into.
  7. mysql_connect("localhost", "user", "pass") or die(mysql_error());
  8. mysql_select_db("stock") or die(mysql_error());
  9. $query="SELECT category FROM subcategory_table";
  10. /* You can add order by clause to the sql statement if the names are to be displayed
  11. in alphabetical order */
  12. $result = mysql_query ($query);
  13. echo "<select name='category'>";
  14. // printing the list box select command
  15. while($nt=mysql_fetch_array($result)){//Array or records stored in $nt
  16. echo "<option value=$nt[category]>$nt[category]</option>";
  17. /* Option values are added by looping through the array */
  18. }
  19. echo "</select>";// Closing of list box
  20. ?>
  21.  
  22. echo '<option value="' . $nt[category] . '">' . $nt[category] . '</option>';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement