0

can i put more then just 1 int in where mysqli select. and can i put var in at.

$selectQuery22 = mysqli_query($db,
    "SELECT * FROM `messages` WHERE `user_id` in(21,2) ORDER BY  `date`DESC");

i put in where some id but i have more then one or two , can i make at working with out any intervention from me.

WHERE user_id in(21,2)  

i need to put more the one id but Automatically with out writng and the ids at is in a variable , Please help me and sorry if i did not clear my point

Added from comments

$bb = $rowpro1->id;
$sess = mysqli_query($db,"SELECT * FROM fmds WHERE user_one = $bb or user_two ='$bb' "); 
$user = $_GET['news']; 
while ($ty = mysqli_fetch_object($sess)) { 
    $ided= $ty->user_two; 
    $ided1= $ty->user_one; 
} 
$selectQuery22 = mysqli_query($db,"SELECT * FROM messages WHERE user_id in(21,2) ORDER BY dateDESC"); 
while ($row = mysqli_fetch_array($selectQuery22)){

Second comment

$usera =mysql_real_escape_string($_SESSION['username']) ;
$selectQuery1 = mysqli_query($db,"SELECT id FROM account WHERE username = '$usera'"); 
if ($_SESSION[username] == true) { 
    $sha = mysqli_query($db,"SELECT * from account1 where username = '$usera'"); 
    $numpro = mysqli_num_rows($sha); 
} 
if ($numpro == 0) { 
}else{ 
    $rowpro1 = mysqli_fetch_object($sha); 
    $rowpro2 = mysqli_fetch_array($sha); 
    $bb = $rowpro1->id; 
} 
$cocos = mysqli_query($db,"SELECT id from freind_req where too ='$bb'"); 
$num_rows = mysqli_num_rows($cocos); 
?>
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
  • your question is unclear? put some code effort and let us know where you are facing problem? – Alive to die - Anant Oct 02 '16 at 18:47
  • This is very unclear. What exactly are you trying to do, and what isn't working? Questions seeking debugging help ("**why isn't this code working?**") must include the desired behavior, a *specific problem or error* and *the shortest code necessary* to reproduce it **in the question itself**. Questions without **a clear problem statement** are not useful to other readers. See: [How to create a Minimal, Complete, and Verifiable example.](http://stackoverflow.com/help/mcve) – elixenide Oct 02 '16 at 18:48
  • in where , i cant put more then one id, ineed way to extract all spefic id – DoDe Al Hasi Oct 02 '16 at 18:52
  • $bb = $rowpro1->id; $sess = mysqli_query($db,"SELECT * FROM `fmds` WHERE `user_one` = $bb or `user_two` ='$bb' "); $user = $_GET['news']; while ($ty = mysqli_fetch_object($sess)) { $ided= $ty->user_two; $ided1= $ty->user_one; } $selectQuery22 = mysqli_query($db,"SELECT * FROM `messages` WHERE `user_id` in(21,2) ORDER BY `date`DESC"); while ($row = mysqli_fetch_array($selectQuery22)){ – DoDe Al Hasi Oct 02 '16 at 18:53
  • here is my code – DoDe Al Hasi Oct 02 '16 at 18:53
  • $usera =mysql_real_escape_string($_SESSION['username']) ; $selectQuery1 = mysqli_query($db,"SELECT id FROM account WHERE username = '$usera'"); if ($_SESSION[username] == true) { $sha = mysqli_query($db,"SELECT * from account1 where username = '$usera'"); $numpro = mysqli_num_rows($sha); } if ($numpro == 0) { }else{ $rowpro1 = mysqli_fetch_object($sha); $rowpro2 = mysqli_fetch_array($sha); $bb = $rowpro1->id; } $cocos = mysqli_query($db,"SELECT id from freind_req where too ='$bb'"); $num_rows = mysqli_num_rows($cocos); ?> – DoDe Al Hasi Oct 02 '16 at 18:55
  • am doing show freind posts like facebook – DoDe Al Hasi Oct 02 '16 at 18:56

0 Answers0