note 109916 modified in function.implode by levim

From: Date: Tue, 18 Mar 2014 02:52:57 +0000
Subject: note 109916 modified in function.implode by levim
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-198941@lists.php.net to get a copy of this message
Even handier if you use the following: <?php $id_nums = array(1,6,12,18,24); $id_nums = implode(", ", $id_nums); $sqlquery = "Select name,email,phone from usertable where user_id IN ($id_nums)"; // $sqlquery becomes "Select name,email,phone from usertable where user_id IN (1,6,12,18,24)" ?> Be sure to escape/sanitize/use prepared statements if you get the ids from users. --was-- Even handier if you use the following: <?php $id_nums = array(1,6,12,18,24); $id_nums = implode(", ", $id_nums); $sqlquery = "Select name,email,phone from usertable where user_id IN ($id_nums)"; // $sqlquery becomes "Select name,email,phone from usertable where user_id IN (1,6,12,18,24)" ?> http://php.net/manual/en/function.implode.php

« previous php.notes (#198941) next »