LMarie Posted September 11, 2009 Share Posted September 11, 2009 Hi iv created a drop down menu of users and a submit button. and this is what i want the submit button to do: when submit search file.txt for match in user if match then increase number for that user by one and write the new number to file.txt then rederect to a new page iv created the lines in file.txt looks like this: number:name:email any ideas or tips? Link to comment https://forums.phpfreaks.com/topic/173874-search-file-for-drop-down-option/ Share on other sites More sharing options...
shadowfiend20 Posted September 11, 2009 Share Posted September 11, 2009 i dont know weather it will work wid your script or not!! anyways i am assuming you are tryin to search for the files in database... $query = "select * from the_table where 1st_field like \"%$input%\" order by 1st_field"; // EDIT HERE and specify your table and input for the SQL query $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); //and check on the basis of $numrows..like match found or not..and so on ..hope i got ur question right Link to comment https://forums.phpfreaks.com/topic/173874-search-file-for-drop-down-option/#findComment-916565 Share on other sites More sharing options...
LMarie Posted September 11, 2009 Author Share Posted September 11, 2009 im searching for match in a file not a database Link to comment https://forums.phpfreaks.com/topic/173874-search-file-for-drop-down-option/#findComment-916567 Share on other sites More sharing options...
shadowfiend20 Posted September 11, 2009 Share Posted September 11, 2009 and where is dat file plz explain litle bit more as required Link to comment https://forums.phpfreaks.com/topic/173874-search-file-for-drop-down-option/#findComment-916573 Share on other sites More sharing options...
syed Posted September 11, 2009 Share Posted September 11, 2009 Wat you need to do is read each line of the text file into a 2D array. after the data is loaded into a 2D array you can then use a loop and an if statement to loop through the array and do a comparison, you can break out of the loop if you find a match. That's the easy bit. Now you need to increase the number for that record, you could update the array and then create a new file using the data from the array. Link to comment https://forums.phpfreaks.com/topic/173874-search-file-for-drop-down-option/#findComment-916591 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.