hellotea 发表于 2012-09-10 20:18

函数如何返回几个数值?

我是一个刚学PHP的新手,想请教大家一个问题。function getdzdate($tid,$type)
{
$con = mysql_connect("localhost","user","passwd");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("dzdb", $con);
mysql_query("SET NAMES 'GBK'");
$sql="SELECT t.subjectFROMpre_forum_thread t ,pre_forum_post p where t.tid=p.tid and p.first=1 order by t.views DESC limit 10";

$result=mysql_query($sql);
$title = mysql_result($result,0);
return $title;
mysql_close($con);
}上面的函数返回的是一个值,就是说,我在程序里调getdzdate这个函数时返回的只是第一个标题,如果我想返回SQL执行结果的那十个标题应该怎么做呢?

imbiss 发表于 2012-09-11 15:12

返 回 数 组

hbeimf 发表于 2012-09-11 16:15

:em17::em17::em17:楼上正解

fanteathy 发表于 2012-09-17 20:54

返回array,再用list函数分别赋给几个变量就OK了
页: [1]
查看完整版本: 函数如何返回几个数值?