jkkenzie Posted December 22, 2008 Share Posted December 22, 2008 I have a a long list of ID numbers that i want look up from database and get the telephone and cellphone numbers displayed. I want to automate my system so that i just paste all my ID Numbers in a textarea/textbox field on a web form, separated by commas then click the search button and my system looks for the records with those IDs and display the required fields IF they exist. Where i have an issue is where php selects one by one the ID Numbers in the text area field and separates each ID Number from the commas and then move from one to the next ID Number. The rest i know how to do it. thanks Link to comment https://forums.phpfreaks.com/topic/138018-solved-use-text-area-to-search/ Share on other sites More sharing options...
Mark Baker Posted December 22, 2008 Share Posted December 22, 2008 $numbers = explode(',',$textAreaValue); foreach($numbers as $number) { // do something } Link to comment https://forums.phpfreaks.com/topic/138018-solved-use-text-area-to-search/#findComment-721372 Share on other sites More sharing options...
jkkenzie Posted December 22, 2008 Author Share Posted December 22, 2008 And if there is no commas in between? If they are just like as below in the field: 1 2 3 4 5 56 6767 3423 thanks Link to comment https://forums.phpfreaks.com/topic/138018-solved-use-text-area-to-search/#findComment-721381 Share on other sites More sharing options...
Mark Baker Posted December 22, 2008 Share Posted December 22, 2008 And if there is no commas in between? Well you did originally say separated by commas but if each is on its own separate line in the text area, then explode on "\n" Link to comment https://forums.phpfreaks.com/topic/138018-solved-use-text-area-to-search/#findComment-721389 Share on other sites More sharing options...
jkkenzie Posted December 22, 2008 Author Share Posted December 22, 2008 Yes i did say with commas. You were right it worked and also your second one worked. Thanks it worked perfect Topic solved (going to click it) Link to comment https://forums.phpfreaks.com/topic/138018-solved-use-text-area-to-search/#findComment-721396 Share on other sites More sharing options...
sloth456 Posted December 22, 2008 Share Posted December 22, 2008 \n|\r is safer because that would explode by new line or return key. Link to comment https://forums.phpfreaks.com/topic/138018-solved-use-text-area-to-search/#findComment-721400 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.