Deanznet Posted October 20, 2008 Share Posted October 20, 2008 Hey is their anyway to make it so you can import a .txt file and make it appear in a php list box? ??? Link to comment https://forums.phpfreaks.com/topic/129183-php-list-box-import-option/ Share on other sites More sharing options...
Bendude14 Posted October 20, 2008 Share Posted October 20, 2008 whats in the text file? if it is just strings of text on each line? you can get this into array and the fill a list box from there. Is that what you are after? Link to comment https://forums.phpfreaks.com/topic/129183-php-list-box-import-option/#findComment-669761 Share on other sites More sharing options...
Deanznet Posted October 20, 2008 Author Share Posted October 20, 2008 Well, this is what i want to do I want to have a list box and 3 text box The first text box i enter in 123456 Then the second text box i enter in 0 and the third i enter in 10 Then i have the php file post to it self generating numbers in the list box using the value of text box 1 so it would be 1234560 1234561 1234562 1234563 ect.. all the way up to 10 Any Idea? Link to comment https://forums.phpfreaks.com/topic/129183-php-list-box-import-option/#findComment-669786 Share on other sites More sharing options...
Bendude14 Posted October 20, 2008 Share Posted October 20, 2008 <?php if(isset($_POST['generate'])) { $def = trim($_POST['def']); $bot_range = trim($_POST['bot_range']); $top_range = trim($_POST['top_range']); echo "<select>"; for($i = $bot_range; $i<=$top_range; $i++) { echo "<option value=\"$def$i\">$def$i</option>"; }//end for loop echo "</select>"; } ?> <form action="" method="post"> <input type="text" name="def" />Default Number<br /> <input type="text" name="bot_range" />Bottom Range<br /> <input type="text" name="top_range" />Top of Range<br /> <input type="submit" name="generate" value="Generate" /> </form> Link to comment https://forums.phpfreaks.com/topic/129183-php-list-box-import-option/#findComment-669796 Share on other sites More sharing options...
Deanznet Posted October 20, 2008 Author Share Posted October 20, 2008 Awsome Thanks worked Great! Link to comment https://forums.phpfreaks.com/topic/129183-php-list-box-import-option/#findComment-669802 Share on other sites More sharing options...
Bendude14 Posted October 20, 2008 Share Posted October 20, 2008 here i made a few improvements so that leading 0's dont disappear in case you set the bottom range as 0001 etc <?php if(isset($_POST['generate'])) { $def = trim($_POST['def']); $bot_range = trim($_POST['bot_range']); $lng = strlen($bot_range); $top_range = trim($_POST['top_range']); echo "<select>"; for($i = $bot_range; $i<=$top_range; $i++) { echo "<option value=\"$def$i\">$def".str_pad($i, $lng, '0', STR_PAD_LEFT)."</option>"; }//end for loop echo "</select>"; } ?> Link to comment https://forums.phpfreaks.com/topic/129183-php-list-box-import-option/#findComment-669810 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.