<?php
function GetTags(){
$uname=$_GET['uname'];
$uname = iconv("UTF-8","gb2312//IGNORE",$uname);
$conn = mysql_connect("localhost","root","qqaazz");
mysql_select_db("2",$conn);
mysql_query("SET NAMES GBK");
mysql_query("set names utf8");
$sql = "SELECT * FROM `yang_user` WHERE `fullname` = '$uname'";
$result=mysql_query($sql,$conn);
while($row=mysql_fetch_assoc($result))
{
$tags=$row["utype"];
}
return $tags;
}
$utype = GetTags();
echo $utype;
?>
查询到的$tags有多个数据(1,2,3),echo $utype;输出的只有一个数据(1),怎样把数据(1,2,3)全部输出.
function GetTags(){
$uname=$_GET['uname'];
$uname = iconv("UTF-8","gb2312//IGNORE",$uname);
$conn = mysql_connect("localhost","root","qqaazz");
mysql_select_db("2",$conn);
mysql_query("SET NAMES GBK");
mysql_query("set names utf8");
$sql = "SELECT * FROM `yang_user` WHERE `fullname` = '$uname'";
$result=mysql_query($sql,$conn);
while($row=mysql_fetch_assoc($result))
{
$tags=$row["utype"];
}
return $tags;
}
$utype = GetTags();
echo $utype;
?>
查询到的$tags有多个数据(1,2,3),echo $utype;输出的只有一个数据(1),怎样把数据(1,2,3)全部输出.
这样的话,后来的不就把先到的覆盖了吗?
$tags = array();
while($row=mysql_fetch_assoc($result))
{
$tags[]=$row["utype"];
}
{
$tags[]=$row["utype"];
}