t_k_eoh Posted August 15, 2007 Share Posted August 15, 2007 Hi guys, Appreciate if you can help me list out all the items from a file (data.txt) into drop down box for user to select. Eg. inside (data.txt) has Apple Orange Strawberry etc... How do I create a drop down list that can call out everything from data.txt (until end of file)?? Pls help. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/65089-solved-how-to-display-txt-info-into-drop-down-list/ Share on other sites More sharing options...
tibberous Posted August 15, 2007 Share Posted August 15, 2007 <select><?php $items = file("data.txt"); foreach($items as $item){ if(strlen($item = trim($item)) < 1) continue; echo "<option value='$item'>$item</option>"; } ?></select> Should work. Quote Link to comment https://forums.phpfreaks.com/topic/65089-solved-how-to-display-txt-info-into-drop-down-list/#findComment-324843 Share on other sites More sharing options...
aim25 Posted August 15, 2007 Share Posted August 15, 2007 put the hyperlink beside the names, like <a href='www.a.com'>Apples</a>, then use the file_get_contents() to get the contents from the txt file. click here for more info: http://www.php.net/file_get_contents Quote Link to comment https://forums.phpfreaks.com/topic/65089-solved-how-to-display-txt-info-into-drop-down-list/#findComment-324844 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.