setisg Posted November 13, 2006 Share Posted November 13, 2006 Let me start off by saying I am a complete newbie when it comes to php/mysql.I am in the process of creating a register form for my website. In the register form will be a "state" field which I would like to pull from mysql databse. Now from what I know so far I am thinking I should have a separate database called "state" which php can pull from and display to the user on the register form.My question is...How do I get php to pull from the database, display the "states", and then input the users "state" selection into a different database (for example "users")?Of course this is just my speculation of how this should work. If I am wrong please don't hesitate to correct me, thanks!Seth Link to comment https://forums.phpfreaks.com/topic/27148-pulling-states-from-a-database/ Share on other sites More sharing options...
Caesar Posted November 13, 2006 Share Posted November 13, 2006 To display them from an existing table in your database, I suppose you want to do something like this:[code]<?php echo"<select name=\"states\" class=\"dropdown\">"; $query = "SELECT * FROM states ORDER BY name ASC"; $states = $db->query($query, $var); while($row = $db->fetch_row($states)) { echo"<option value=\"$row[0]'>$row[1]"; } echo"</select>";?>[/code]But I suggest you do some reading/research & try to understand how the code works...before trying to implement it. Link to comment https://forums.phpfreaks.com/topic/27148-pulling-states-from-a-database/#findComment-124135 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.