php - Pulling questions based on category & user -
so developing website has questions across different categories, depending on user question different.
an example : team has access questions (cat 1 - question 1, cat 2 - question 2, cat 3, question 3, , cat4 - question 4), , team b has access question (cat 1 - question 5, cat 2 - question 6, cat 4 - question 7)....
so each team have these 4 categories question users may different depending on team id. http://puu.sh/ilyss/2c93f9a0d5.png
so need pull question based on category along based on team , don't know how go linking button when team click web 'view question' button displays questions , team b different question.
here database structure : http://puu.sh/im1d1/caa9c27015.pdf
so far have following :
$order = "select * questionscat order questioncatid";
challenge.php
<div class="row"> <?php while($data = mysqli_fetch_row($result)){ if($data[0] != null){ echo(' <div class="col-md-3 col-sm-6"> <div class="panel panel-default text-center"> <div class="panel-heading"> <span class="fa-stack fa-5x"> <i class="fa fa-circle fa-stack-2x text-primary"></i> <i class="fa fa-question fa-stack-1x fa-inverse"></i> </span> </div> <div class="panel-body"> <h4>'.$data[1].'</h4> <p>'.$data[2].'</p> <a href="question.php?id='.$data[0].'" class="btn btn-primary">view question </a> </div> </div> </div> ');}else{ echo "hello"; } } ?> </div>
i have tried multiple queries cannot right (example)
select q.question,t.questiongroupid,qc.questioncatname questions q inner join questionscat qc on q.questioncatid=qc.questioncatid inner join team t on t.questiongroupid=qc.questioncatid qc.questioncatid=2
so if appreciated! or put me in right direction
regards syn
see want team see other questions when clicked on category coding
. , team b see different questions when clicked on same coding
category.
so in order achieve , have put user type in session
variable hold user type "php_developer" or "sql_dba" etc when user logs in.
now have user type of logged in user.
now when click link of category coding
, goto page category id/name , abc.com/showquestions.php?category=1
or abc.com/showquestions.php?categoryname=coding
.
now on page category id or name can use in where clause
of sql query. want 2nd parameter can filter category question that
group of users. use here session variable stored while login , 2nd condition in where clause
where category = 1 , usertype='".$_session['usertype']."'
.
hope makes sense.
edit : more simplified
select q.question,t.questiongroupid,qc.questioncatname questions q inner join questionscat qc on q.questioncatid=qc.questioncatid inner join team t on t.questiongroupid=qc.questioncatid qc.questioncatid=2 , t.questiongroupid = '".$_session['usertype']."'
Comments
Post a Comment