Jump to content

search file for drop down option


LMarie

Recommended Posts

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

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

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.