php - MYSQL Statement with Array Variable -


so have following mysql statement saving array:

$sql = "select did did id = '$did_id'";   $result = mysqli_query($link, $sql, mysqli_store_result);     while($row = $result->fetch_row()){        $did[] = $row;        } 

that part works great. need take values in $did array , perform lookup using values in it. way works have users assigned did's. find did's user assigned (the $did array) , show them results table based on did values. have no idea how part works, next statement needs do:

   select * log did_id = "the values in $did array" 

hope can help. appreciate it. haven't been able find on it.

you can use php's join mysql's in make comma separated strings can use implode , join() alias of implode();

select * log did_id in( ".join(',',$did).") 

one thing mention here $did should contains ids in manner

array("1","2","3"....) 

so in loop fetch first index holds did column value

$did[] = $row[0]; 

note: i assume did , did_id type int or bigint


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -