$string="1,2,3,4,5"; $array=array_map('intval', explode(',', $string)); $array = implode("','",$array); $query=mysqli_query($conn, "SELECT name FROM users WHERE id IN ('".$array."')");
NB: the syntax is:
SELECT * FROM table WHERE column IN('value1','value2','value3')
Related Posts:
- Difference between “as $key => $value” and “as $value” in PHP foreach
- How to log in to phpMyAdmin with WAMP, what is the username and password?
- Array to String PHP?
- Should I use mysqli_real_escape string() or mysql_real_escape_string() for form data?
- Fatal error: Call to undefined function mysql_connect()
- “Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset” using PHP
- PDOException SQLSTATE[HY000] [2002] No such file or directory
- http://localhost:80 is not working on running Apache server through UniServer ZeroXIII
- PDOException SQLSTATE[HY000] [2002] No such file or directory
- Mysql query- How to use contains?
- mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in
- Invalid column count in CSV input on line 1 Error
- Invalid column count in CSV input on line 1 Error
- Convert a PHP object to an associative array
- How to echo or print an array in PHP?
- $wpdb->update or $wpdb->insert results in slashes being added in front of quotes
- PDO with INSERT INTO through prepared statements
- phpMyAdmin: secret passphrase?
- PDO bindParam() with prepared statement isn’t working
- Forbidden :You don’t have permission to access /phpmyadmin on this server
- Deleting an element from an array in PHP
- How to insert an item at the beginning of an array in PHP?
- Creating a search form in PHP to search a database?
- How can I do ‘insert if not exists’ in MySQL?
- Fatal error: Call to a member function bind_param() on boolean [duplicate]
- what is a good method to sanitize the whole $_POST array in php?
- Sort array of objects by object fields
- MySqli Commands out of sync; you can’t run this command now
- Trying to get property of non-object in
- Fix Access denied for user ‘root’@’localhost’ for phpMyAdmin
- Getting connection failed: php_network_getaddresses: getaddrinfo failed: Name or service not known
- Commands out of sync; you can’t run this command now
- Lost connection to MySQL server at ‘reading initial communication packet’, system error: 0
- In_array not working
- PHP with MySQL 8.0+ error: The server requested authentication method unknown to the client
- SQLSTATE[HY093]: Invalid parameter number: parameter was not defined
- PHP multidimensional array search by value
- How can I do ‘insert if not exists’ in MySQL?
- Fatal error: Cannot use object of type mysqli_result
- Object of class DateTime could not be converted to string
- What does it mean to escape a string?
- Convert from MySQL datetime to another format with PHP
- MAMP “Apache couldn’t be started because port is in use.” AND “Can’t connect to local MySQL server through /tmp/mysql.sock
- mysqli::query(): Couldn’t fetch mysqli
- Unexpected Exception: SQLSTATE[HY000] [1045] Access denied for user ****@’localhost’ (using password: YES)
- php foreach with multidimensional array
- Convert php array to Javascript
- Uncaught Error: Call to undefined function mysql_escape_string()
- Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in
- Call to a member function on null?
- SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens on line 102
- PHP reindex array?
- Warning: mysqli_query() expects parameter 1 to be mysqli, resource given
- MySQL query to get column names?
- What does MYSQLI_NUM mean and do?
- php – How do I fix this illegal offset type error
- ERROR: SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it
- What is the advantage of using try {} catch {} versus if {} else {}
- How to convert array to SimpleXML
- select * from table where column = value ^ column2= value
- Deprecated: mysql_query() [duplicate]
- Array of PHP Objects
- Is there a function to make a copy of a PHP array to another?
- How to Sort a Multi-dimensional Array by Value
- PHP array printing using a loop
- Fastest way to implode an associative array with keys
- No query results for model [App\Products] Laravel
- Fatal error: Call to a member function query() on null
- mysqlworkbench giving version error on exporting database
- How to make DROP INDEX IF EXISTS for mysql?
- What is the meaning of sprintf(): Too few arguments
- PHP array delete by value (not key)
- Having a problem getting mysqli_query to execute
- CodeIgniter: Unable to connect to your database server using the provided settings Error Message
- Can I store images in MySQL
- MySQL Daemon Failed to Start – centos 6
- PHP Multiple Checkbox Array
- How to insert TIMESTAMP into my MySQL table?
- How to remove index.php from WordPress site URL
- Display array values in PHP
- Reset PHP Array Index
- PHP Like thing similar to MySQL Like, for if statement?
- How get value from URL
- How to push both value and key into PHP array
- How to use Memcached with PHP7?
- Remove empty array elements
- select count(*) from table of mysql in php
- You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ””)’ at line 2
- count() parameter must be an array or an object that implements countable in laravel
- Resize image in PHP
- How to create cron job using PHP?
- Imploding an associative array in PHP
- NotFoundHttpException in RouteCollection.php line 161: in laravel 5
- Easy way to password-protect php page
- Authenticating in PHP using LDAP through Active Directory
- What is /var/www/html? [closed]
- Show MySQL errors that occur when I excute $wpdb->insert()
- Large Woocommerce Site (83,000 items), What Can I Do? [closed]
- WordPress WP_Query without query GET parameters
- Query the links Database