I have fetched a column values in a variable from table1 and trying to use that variable to fetching another column values from table2 with WHERE clause.
I'm trying the below code, where $theseOpCode is holding the OpCode column values from user_profile table. I want to fetch values from $table WHERE OpCode='$theseOpCode'. I also tried WHERE IN ($theseOpCode) but no luck.
Someone please show me the right way.
index.php
$query=mysql_query("SELECT * FROM user_profile WHERE email='$thisEmail'") or die(mysql_error());
while($row = mysql_fetch_array($query)) {
$theseOpCode = $row['OpCode'];
$_SESSION['Op'] = $theseOpCode;
}
I m trying to get the $theseOpCode as a session, and use this variable in WHERE clause in another file where my show class is.
showClass.php
class showClass{
public function showUser($table){
$theseOpCodeVal = $_SESSION['Op'];
$query=mysql_query("SELECT * FROM $table WHERE OpCode='$theseOpCodeVal'") or die(mysql_error());
$data=NULL;
if(mysql_num_rows($query)>0){
while($rows=mysql_fetch_assoc($query)){
$data[]=$rows;
}
return $data;
}else{
echo '<span class="text-info success">No Account Found.</span>';
exit();
}
}
}
My code is working but only showing the last value from WHERE clause. But I have 6 values in the $theseOpCodeVal variable. I want to fetch all values that matches $theseOpCodeVal variable values not only the last value that matched.