php - Store multiple rows from mysql database into one single variable -


this hard me, i'm trying store multiple rows table in mysql single variable


$mysql_statementjc = "select * `dog`.`cat` `name` = '$name'"; $mysql_commandjc = mysql_query($mysql_statementjc);    while($row = mysql_fetch_array($mysql_commandjc)){      $followi = $row['industry'];      $groupconcat = $followi . " or ";      echo $groupconcat; } 

this appproach, @ end of can "sam, john, bob" saved $groupconcat can used elsewhere.

many thanks.

each time through loop, add desired value array. then, after loop, use implode() function create desired output.

while($row = mysql_fetch_array($mysql_commandjc)){      $followi = $row['industry'];      $resultarray[] = $followi; }  $groupconcat = implode(" or ", $resultarray);  echo $groupconcat; 

note should stop using mysql library , instead use mysqli or pdo.


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -