请问我这样写对不对,谢谢?? 是啊,我是刚学的php,还请高手指教 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 一个小函数,应该能看懂吧: /** * 选择新闻列表 * * @param int $from * @param int $to * @return array */ function get_all_news($from, $to, $condition = '') { $sql = 'select id, title, url, updatetime, (select count(id) from matter_news ' . $condition . ') as t from matter_news ' . $condition . ' order by id desc limit ' . $from . ', ' . $to; $result = mysql_query($sql); $i = 0; while ($row = mysql_fetch_array($result)) { $r[$i]['id'] = $row['id']; $r[$i]['title'] = $row['title']; $r[$i]['url'] = $row['url']; $r[$i]['time'] = $row['updatetime']; $r[$i]['total'] = $row['t']; $i++; } return $r; } 你要实现什么功能?是这样?if(($n = mysql_num_rows($result)) == 0){ // 没选到数据要做的操作}else{ // 选到数据要做的操作}建议LZ看看手册~ php 绝对路径问题 Discuz和PHPWind相比哪个使用Ajax技术少? 继承过UCenter1.5 的进啊 有几个简单的问题 php 解析xml问题 eclipse + php ? 比较麻烦的重写 提取这个网页的数据,正则怎么写呢? 如何在一个页面里头改变刷新另一个页面?急 谁知道ultraedit 9.10怎么注册? 关于学习PHP的点点滴滴 以下代码,为什么不能成功的删除数据呢 php连接Oracle,使用原来的过程函数,还是PDO好??
/**
* 选择新闻列表
*
* @param int $from
* @param int $to
* @return array
*/
function get_all_news($from, $to, $condition = '')
{
$sql = 'select id, title, url, updatetime, (select count(id) from matter_news ' . $condition . ') as t from matter_news ' . $condition . ' order by id desc limit ' . $from . ', ' . $to;
$result = mysql_query($sql);
$i = 0;
while ($row = mysql_fetch_array($result))
{
$r[$i]['id'] = $row['id'];
$r[$i]['title'] = $row['title'];
$r[$i]['url'] = $row['url'];
$r[$i]['time'] = $row['updatetime'];
$r[$i]['total'] = $row['t'];
$i++;
}
return $r;
}
{
// 没选到数据要做的操作
}
else
{
// 选到数据要做的操作
}建议LZ看看手册~