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. 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. 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 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
Archived
This topic is now archived and is closed to further replies.