nel Posted August 31, 2006 Share Posted August 31, 2006 i have some data for example : [B]data_name value [/B] place USA place UK place RUSIA place CHINA place JAPANso how i can call from database this data into select, radio and check box.for example: place: <select name=place> <option value=USA>USA</option> <option value=USA>USA</option> <option value=USA>USA</option>and more .... Quote Link to comment Share on other sites More sharing options...
shocker-z Posted August 31, 2006 Share Posted August 31, 2006 can't make out if your wanting to display data from the table into the select box or if your wanting to use the data to be inserted into the database? here is how you would echo the data from the database into a select.[code]//your connection up here$query=mysql_query("SELECT * FROM tablename") or die(mysql_error());echo '<select name=place>';while ($row=mysql_fetch_array($query)) {echo "<option value=$row[data_name]>$row[value]</option>"}echo '</select>';[/code]RegardsLiam Quote Link to comment Share on other sites More sharing options...
nel Posted August 31, 2006 Author Share Posted August 31, 2006 thanks for the code..but i still have a problem..in this code i use while function to call all the data from table_name.so when running the code it will create many select statement according to my value in select list...i hope you can help me...thanks a lot Quote Link to comment Share on other sites More sharing options...
shocker-z Posted August 31, 2006 Share Posted August 31, 2006 not if you put the <select> and </select> outside of the while loop. Quote Link to comment Share on other sites More sharing options...
nel Posted August 31, 2006 Author Share Posted August 31, 2006 i'm not understand yet...i have 1 question:i want to insert data using array. i get the data from $_post.when data inserted its showed for example: data_name value place USA place UK place RUSIA place CHINA place JAPANso i want you to help me, how to insert place and USA in first inserting and next inserting only for value.this because i want to get this data back in select statement.thanks. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted August 31, 2006 Share Posted August 31, 2006 Does it have to be at the beginning? If not you can add it to the array using array_push():http://uk2.php.net/array_pushIf you're adding it into the database then run a SELECT query to pull the data and sort it all into alphabetical order:[code]SELECT * FROM table ORDER BY `value` ASC[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.