TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sayuj Raghavan
NA
52
7k
How to use array values in Where Clause in MySQL?
Apr 18 2016 4:45 AM
Hi , this is the code which i am working on,
<?php
public function Welcome_Students($uid)
{
$q=mysqli_query($this->db,"SELECT School_Name FROM school_teacher_reg WHERE csr='$uid'")or die(mysqli_error($this->db));
while($row1=mysqli_fetch_array($q,MYSQLI_ASSOC))
{
$Schoolname=$row1[School_Name];
}
$q1=mysqli_query($this->db,"SELECT csr FROM school_student WHERE sch_name='$Schoolname'")or die(mysqli_error($this->db));
while($row3=mysqli_fetch_array($q1,MYSQLI_ASSOC))
{
$csr[]= $row3; //till here i am getting the output
foreach($csr as $key){
$query=mysqli_query($this->db,"SELECT U.username,U.uid,U.bio FROM users U WHERE U.status='1' AND U.uid='$key' ORDER BY RAND() LIMIT 10")or die(mysqli_error($this->db));
while($row=mysqli_fetch_array($query,MYSQLI_ASSOC))
{
$data[]=$row;
}
}
return data;
} }
?>
I have been successfull executing till $csr[]= $row3; where i am able to fetch $csr[] array values .But when i try to fetch each values of that array in $csr[], I am unable to retrieve values from the table using the following query inside the foreach loop
"SELECT U.username,U.uid,U.bio FROM users U WHERE U.status='1' AND U.uid='$key' ORDER BY RAND() LIMIT 10").
Reply
Answers (
12
)
How to create user Privacy Privilages like facebook?
Webservices in PHP for picture upload