implode query

28 views
Skip to first unread message

Reece Jones

unread,
Apr 6, 2017, 7:30:00 AM4/6/17
to Fat-Free Framework
$fixtures = array();
$fixtures = mysqli_query($db_connect, "SELECT `fixtureid` FROM `myfixtures` WHERE `id`='".$_SESSION['usr_id']."'"); 

$new = array();
//$all = mysqli_fetch_assoc($fixtures);
while(($row = mysqli_fetch_array($fixtures))) {
   $new[] = $row;
}

$all = array_column($new, 'fixtureid');

var_dump($all);

 $result = mysqli_query($db_connect, "SELECT * FROM `fixtures` WHERE `fixtureid` (" . implode(",",$all) . ")");

Hi, wondering if anybody could help, the vardump shows..

array (size=3)
  0 => string '11' (length=2)
  1 => string '11' (length=2)
  2 => string '63' (length=2)


The $result query is returning false and im not sure why, ive tried everything, 

thanks.

ved

unread,
Apr 6, 2017, 7:42:07 AM4/6/17
to f3-fra...@googlegroups.com
 $result = mysqli_query($db_connect, "SELECT * FROM `fixtures` WHERE `fixtureid` (" . implode(",",$all) . ")");

I think you're missing an IN() statement. Should probably be "WHERE fixtureid IN(val1,val2)" 

ikkez

unread,
Apr 6, 2017, 7:48:11 AM4/6/17
to Fat-Free Framework
you missded the IN statement:  "WHERE `fixtureid` IN ("

Reece Jones

unread,
Apr 6, 2017, 8:07:23 AM4/6/17
to Fat-Free Framework
thanks!

Reece Jones

unread,
Apr 6, 2017, 8:07:41 AM4/6/17
to Fat-Free Framework
thanks!
Reply all
Reply to author
Forward
0 new messages