求一个数组问题!! 我想到的方法比较笨就是按每个id来读取,但是这样要按id读好多次我就是想用数组或其他方法来实现在简单的 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 where in(……)前台做缓存 selectid,contentfromtablewhereid in ('1','2','3','4','5','6')order by id asc 4楼回答得挺好,就这么做的!整理成这样的sql运行即可。 4楼这样的读出来后.要怎么读取id对应的content呢. 这样的读出来的结果,给他变成一个array然后foreach $key $value就出来了 准备$ar = array(1,3,2,4,6,5);$p = array_flip($ar);$t = join(',', $ar); //适用于id为数值型$t = "'" . join("','", $ar) ."'"; //适用于id为字符型$sql = "select id, content from tbl_name where id in ($t)";查询$rs = mysql_query($sql);获取结果while($r = mysql_fetch_assoc($rs)) { $p[$r['id']] = $r['content'];}结果数组中,键为id,值为content 请教各位大侠关于删除服务器中文件的问题 file_exists 的查找速度。 PHP怎么把img标签从一段html代码中提取出来 文章每段前留两个空格是如何实现的? 如何在PHP中限制文本框的字数,类型等,求完整代码 或 文挡什么的. 请问如何转换成这种形式的数据? DreamWeaver可以用來編寫php網頁嗎? php有没有像ASP那样的Application对象或变量? 显示问题! php怎样包含远程web服务器上的文件? 求教 PHP+mssql+utf-8(韩文 维文 ……) 一个初学PHP的问题.
前台做缓存
id
,content
from
table
where
id in ('1','2','3','4','5','6')
order by id asc
$ar = array(1,3,2,4,6,5);
$p = array_flip($ar);
$t = join(',', $ar); //适用于id为数值型
$t = "'" . join("','", $ar) ."'"; //适用于id为字符型
$sql = "select id, content from tbl_name where id in ($t)";查询
$rs = mysql_query($sql);获取结果
while($r = mysql_fetch_assoc($rs)) {
$p[$r['id']] = $r['content'];
}结果数组中,键为id,值为content