douwen8424 2015-02-05 21:31
浏览 21

传递值并在php中返回多个值

HOw to Call Two Values from php Function with passing some values to function

class insert //  Class for cheking
{
public function Read($variable)// Read Values From Database
{
//echo $variable;
$read=mysql_query($variable);

$r=""; // Var For Storage Multiple Values
$r1="";


while($res=mysql_fetch_array($read))
{
if($res["Temp"]=="Temp")
{
$r.=$res["Selection"].",";  
}
if($res["Temp"]!=="Temp")
{
$r1.=$res["Selection"].","; 
}
}// class close

and Now I am calling function

$data=new insert();
$bar=$data->Read("passing Some MySql Code");

My Problem is how to call $r and $r1 Temp Is some Column in My MYsql Table and i am checking with that Temp='Temp' where temp equal to or not equal to i want read out put

  • 写回答

2条回答 默认 最新

  • 普通网友 2015-02-05 21:43
    关注

    You can try this:

    class insert //  Class for cheking
    {
        public function Read($variable)// Read Values From Database
        {
            //echo $variable;
            $read = mysql_query($variable);
    
            $data = array(); // Var For Storage Multiple Values
    
            while($res = mysql_fetch_array($read))
            {
                if($res["Temp"]=="Temp")
                {
                    $data['one'] .= $res["Selection"].",";  
                }
                if($res["Temp"]!=="Temp")
                {
                    $data['two'] .= $res["Selection"].","; 
                }
            }
    
            return $data;
        }
    }// class clos
    
    //Call
    
    $data=new insert();
    $bar=$data->Read("passing Some MySql Code");
    
    echo("<p>bar:one = ".$bar['one']."</p>");
    echo("<p>bar:two = ".$bar['two']."</p>");
    
    评论

报告相同问题?

悬赏问题

  • ¥15 vscode的问题提问
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM