php - passing array to string not ok -
this question has answer here:
- making array database [closed] 1 answer
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
Post a Comment