php - query to display video links from a table which match inserted checkbox values in another table -


i need query not have knowledge implement. aware mysql functions deprecated website prototype not important purpose of project.

i have site used display video tutorials users training purposes. users presented list of 14 questions checkboxes, can tick relevant checkboxes , view each associated tutorial on next page.

the user_id of person logged on inserts database can identify has selected checkboxes, along each checkbox value (1 or 0) seperate column in answers table (enisatanswer). here code inserting working fine. select statement @ start maintain session details of user, , used across each page.

<?php   session_start(); include_once 'dbconnect.php';  if(!isset($_session['user'])) {  header("location: index.php"); } $res=mysql_query("select * users user_id=".$_session['user']); $userrow=mysql_fetch_array($res);  if(isset($_post['submit'])) {   header("location: enisatvids.php");  @$userid=$_session['user']; @$checkbox1=$_post['log']; @$checkbox2=$_post['worktray']; @$checkbox3=$_post['visual']; @$checkbox4=$_post['changepd'];  @$checkbox5=$_post['logout']; @$checkbox6=$_post['clientsearch']; @$checkbox7=$_post['startassessment']; @$checkbox8=$_post['finalise']; @$checkbox9=$_post['print']; @$checkbox10=$_post['hcn']; @$checkbox11=$_post['lcid']; @$checkbox12=$_post['soscare']; @$checkbox13=$_post['reassign']; @$checkbox14=$_post['close'];      $query="insert enisatanswer (user_id,log,worktray,visual,changepd,logout,clientsearch,startassessment,finalise,print,hcn,lcid,soscare,reassign,close) values      ('$userid', '$checkbox1', '$checkbox2','$checkbox3', '$checkbox4', '$checkbox5', '$checkbox6','$checkbox7', '$checkbox8','$checkbox9', '$checkbox10','$checkbox11', '$checkbox12', '$checkbox13', '$checkbox14')";       mysql_query($query) or die (mysql_error() ); if($query==true)    {         echo'<script>alert("your choices have inserted \n \n please click on display enisat tutorials @ buttom of page view videos ")</script>';      }   else      {         echo'<script>alert("failed insert")</script>';      }   }   ?>  <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>welcome - <?php echo $userrow['username']; ?></title> /<link rel="stylesheet" href="style.css" type="text/css" /> </head> <body> <div id="header">  <div id="left">     <label>nhsct enisat tutorials</label>     </div>     <div id="right">      <div id="content">          welcome <?php echo $userrow['forename']; ?>&nbsp;<a href="logout.php?logout">sign out</a>         </div>     </div> </div> <br> <p align="center"><img src="title.jpeg" width="400"height="100" alt="title.jpeg"> <br> <br> <center> <h2>please select tasks require assistance with, before clicking display enisat tutorials:<h2> <br> <table align="center" height="0" width="70%" border="1" bgcolor = "white">    <form  action="" method="post"     <tr>        <td colspan="2">tick each relevant box:</td>      </tr>      <tr>         <td>how login</td>         <td><input type="checkbox" name="log" value="1"></td>       <tr>         <td>how manage worktray</td>         <td><input type="checkbox" name="worktray" value="1"></td>      <tr>         <td>how change visual settings (colours , text size)</td>         <td><input type="checkbox" name="visual" value="1"></td>     </tr>      <tr>         <td>how change own password on system</td>         <td><input type="checkbox" name="changepd" value="1"></td>      </tr>      <tr>         <td>how logout of system</td>         <td><input type="checkbox" name="logout" value="1"></td>     </tr>      <tr>         <td>how search client on system</td>         <td><input type="checkbox" name="clientsearch" value="1"></td>     </tr>      <tr>        <td>how start assessment</td>         <td><input type="checkbox" name="startassessment" value="1"></td>     </tr>      <tr>       <td>how finalise assessment</td>         <td><input type="checkbox" name="finalise" value="1"></td>      <tr>         <td>how print assessment</td>         <td><input type="checkbox" name="print" value="1"></td>      </tr>      <tr>         <td>how create client , referral manually through find on h+c</td>         <td><input type="checkbox" name="hcn" value="1"></td>      </tr>      <tr>         <td>how submit referral lcid (lcid users only)</td>         <td><input type="checkbox" name="lcid" value="1"></td>     </tr>      <tr>         <td>how submit referral soscare (soscare users only)</td>         <td><input type="checkbox" name="soscare" value="1"></td>     </tr>      <tr>         <td>how reassign referral on enisat</td>         <td><input type="checkbox" name="reassign" value="1"></td>     </tr>      <tr>         <td>how close referral on enisat</td>         <td><input type="checkbox" name="close" value="1"></td>    </tr>     <tr>         <td  <td><button name="submit" type="submit" onclick="window.location.href='enisatvids.php'">display enisat tutorials</button></td> </tr>  </table>   </div>   </form>   </body>   </html>  

my next page @ present displays links in table 14 of videos questions table 'enisatquestion'.

my question is, can me query display video links the checkboxes selected user, instead of them all. guessing in order variable need created each column 'enisatanswer' table. columns (log,worktray,visual etc)

so query presume like:

select * enisatquestion enisatanswer (log,worktray,visual....) values =1 , user_id = $userid=$_session['user']; 

i not sure statement

any appreciated. here code display videos

<?php        session_start();     include_once 'dbconnect.php';      if( !isset( $_session['user'] ) ) header("location: index.php");      $res=mysql_query("select * users user_id=".$_session['user']);     $userrow=mysql_fetch_array( $res );      $query = "select enisatquestion, enisatvideo enisatquestion";      $result = mysql_query( $query );     /* default message if query fails or there no records */     $enisatquestion='<h2>sorry, there no records</h2>';       /* cannot output content outside html tags, not valid ~ work no */     if( $result ) {/* if there recordset, proceed , generate html table */         $enisatquestion = "<table >";         while ( $row = mysql_fetch_assoc($result) ) {             $enisatquestion .= "<tr><td><a href='{$row['enisatvideo']}'>{$row['enisatquestion']}</a></td></tr>";         }         $enisatquestion .= "</table>";         } ?>  <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>welcome - <?php echo $userrow['username']; ?></title> <link rel="stylesheet" href="style.css" type="text/css" /> </head> <body> <div id="header">  <div id="left">     <label>nhsct enisat tutorials</label>     </div>     <div id="right">      <div id="content">          welcome <?php echo $userrow['forename']; ?>&nbsp;<a href="home.php?home">return homepage</a>&nbsp;&nbsp;<a href="logout.php?logout">sign out</a>         </div>     </div>     <br>     <br>     <br>     <br> <p align="center"><img src="title.jpeg" width="400"height="100" alt="title.jpeg"> <br> <br>     <center>    <h2>click on each link open tutorial in windows media player<h2>    <br>     <?php         /* output html table here, below header */         echo $enisatquestion;         /*             if query failed default gets displayed         */     ?>   </div>  </body>   </html> 


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -