php - passing array to string not ok -


this question has answer here:

i have script , im having problem passing array string commas. want string can insert variable inside query in select...where... in($variable); tried implode , dont echo ids string echoes array.

error_reporting(e_all); mysql_connect("localhost", "root", "root"); mysql_select_db("wall");  $sql = "select id table id=1"; $result = mysql_query( $sql);  $myarray=''; while($row = mysql_fetch_array($result)){     $popurl = $row['id'];     $myarray[] = $popurl; }  echo "<pre>"; print_r($myarray); 

try code:

$myarray= array() ; //here must declare array while($row = mysql_fetch_array($result)){    $popurl = $row['id'];    $myarray[] = $popurl; }  $string = "'" . implode("', '", $myarray) . "'" ;  //will make ready string 'data','data2', 'data3' 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -