用implode函数链接所有的操作ID

//链接搜索条件

$wheresql = implode(' AND ', $wherearr);	//链接搜索条件

 
//连接字符
function simplode($ids) {
	return "'".implode("','", $ids)."'";
}
 
//LIST UPDATE
  $itemidarr = array(); //初始化itemidarr数组
  if(empty($_POST['item'])) {  //判断提交过来的是否存在待操作的记录,如果没有,则显示提示信息并退出
   showmessage('space_no_item');
  }
  $itemidstr = simplode($_POST['item']); //用逗号链接所有的操作ID
  //对提交的数据进行检查

实例代码:

	//catid UPDATE
	$catidarr = array();
	if(!empty($t1)) $catidarr[] = '\''.$t1.'\'';
	if(!empty($t2)) $catidarr[] = '\''.$t2.'\'';
	if(!empty($t3)) $catidarr[] = '\''.$t3.'\'';
	
	$catidstr = implode(' , ', $catidarr);	//用逗号链接所有的操作ID

SQL语句示例:

SELECT uid, name, namestatus FROM ".tname('space')." WHERE uid IN (".simplode($uids).")

相关文章:

1、CentOS 7.8 系统yum环境搭建PHP 7.4.x + Apache 2.4 + MariaDB 10.x
https://www.onexin.net/centos-7-x-php-7-x-apache-2-4-mariadb-10-x/

2、SWOOLE HOOK CURL 同步IO变异步IO
https://www.onexin.net/swoole-hook-curl/

3、CentOS 8.2 服务器上yum安装Apache+Php+MariaDB+MongoDB
https://www.onexin.net/centos-8-2-yum-apache-php-mariadb-mongodb/

4、PHP描述冒泡排序和快速排序算法
https://www.onexin.net/php-description-of-bubble-sort-and-quicksort-algorithm/

5、用C/C++扩展你的PHP 为你的php增加功能
https://www.onexin.net/cc-extensions-your-php-to-add-functionality-to-your-php/

转载请注明出处:https://www.onexin.net/link-to-all-of-the-operations-by-commas-id/

Leave a Reply

Your email address will not be published. Required fields are marked *