Jump to content

Textarea list vs database entries


triphp

Recommended Posts

I have a textarea wherein users can input a string, i.e. names for example, line by line. And in my database I have a table that store the names.

I want to compare the names (one name per line) he entered in the textarea versus the names in the database. If the names he entered in the textarea is not yet in the database, it will be echoed back.

Does anyone know how to do the comparison? Is there a built-in function in PHP to do this? Any help or examples give is greatly appreciated :)
Link to comment
Share on other sites

I think you can do an array compare against two arrays, that would probably be the way to go... Look at [url=http://uk.php.net/manual/en/function.array-diff.php]array_diff()[/url].

Get both sets of data into an array, this should be pretty simple, if you're not sure, give us a shout back.

Regards
Huggie
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.