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
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

 

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.