Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 746173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T09:40:06+00:00 2026-05-14T09:40:06+00:00

Trying to check if a name is already stored in the database from the

  • 0

Trying to check if a name is already stored in the database from the login user. The name is a set of dynamic arrays entered by the user threw a set of dynamic form fields added by the user. Can some show me how to check and see if the name is already entered by the login user? I know my code can’t be right. Thanks!

MySQL code.

SELECT * 
FROM names 
WHERE name = '" . $_POST['name'] . "' 
AND userID = '$userID'

Here is the MySQL table.

CREATE TABLE names (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
userID INT NOT NULL,
name VARCHAR(255) NOT NULL,
meaning VARCHAR(255) NOT NULL,
PRIMARY KEY (id)
);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T09:40:07+00:00Added an answer on May 14, 2026 at 9:40 am

    If $_POST[‘name’] is actually an array of strings, as you say, then try this PHP:

    $namesString = '';
    foreach ($i=0; $i < count($_POST['name']) $i++)
    {
        $namesString .= "'" . mysql_real_escape_string($_POST['name'][$i]) . "'";
        if(isset($_POST['name'][$i + 1]) $nameString .= ', ';
    }
    

    With this query:

     SELECT * FROM `names` 
     WHERE `name` IN ( $namesString )
        AND `userID` = '$userID'
    

    The query will return all the rows in which the name is the same as string in $_POST[‘name’].

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am trying to check my user name is if its available to register
I am trying to check if certain ID already exists in database. When it
I am trying to check if a user is a member of an Active
I have been trying to check my arraylist to see if an object already
I'm trying to verify that an Account Name is not already in use once
I'm trying to get data from the database in order to create a list
I am trying to create a user login/creation script in PHP and would like
I am trying to check if a date has passed or if it is
I am trying to check for locked accounts in AD. In a few snippets
I'm trying to check in jQuery if a div contains some text, and then

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.