Store multiple rows from mysql database into one single variable

后端 未结 3 1894
盖世英雄少女心
盖世英雄少女心 2021-01-24 12:23

this is really hard for me, i\'m trying to store multiple rows from my table in mysql into a single variable


$mysql_statementJc = \"SELECT * FROM `dog`.`ca         


        
3条回答
  •  滥情空心
    2021-01-24 12:52

    You can also do it as:

    $followl = array();
    
    while($row = mysql_fetch_array($mysql_commandJc))
    { 
        $followl[] = $row['industry'];
    }
    
    $groupConcat = implode(" OR ",$followl);
    echo $groupConcat;
    

    Some Explanation:

    Store values into an array $followl and than use implode() function for imploding with OR.

    Side note:

    Please use mysqli_* or PDO becuase mysql_* is deprecated and no more available in PHP 7.

提交回复
热议问题