Store multiple rows from mysql database into one single variable

后端 未结 3 1892
盖世英雄少女心
盖世英雄少女心 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 13:04

    Each time through the loop, add the desired value to an array. Then, after the loop, use the implode() function to create your desired output.

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

    Note that you should really stop using the mysql library and instead use mysqli or PDO.

提交回复
热议问题