I have created a site for a uni project where users can login to get video tutorials. This is only a prototype so I only need it to have basic functionality, everything is on localhost so security is not paramount.
Users are presented with a 14 checkboxes one for each tutorial. I am able to insert each checked box into my table (enisatanswer) into separate columns (Log, Worktray, Visual) etc, with the same value/name as my column as well as the primary key from my users table (user_id) through sessions. My enisatanswers table resembles this
COLUMNS: user_id Log Worktray Visual Finalise Logout
ROWS 1 Log Visual Finalise
2 Worktray Visual Finalise
3 Log Worktray Visual Finalise Logout
I have 14 html files which correspond to each checkbox (LoginTutorial.html, WorktrayTutorial.html, VisualTutorial.html) which have each video embedded into them. They are wmv files which is the essential format I need unfortunately, as far as I aware HTML5 is not an option from other questions I have read (correct my please if I am wrong). When the html files are run independently they play my video in IE. Here is an example of one o the files.
LoginTutorial.html
<object width="100%" height="100%"
type="video/x-ms-asf" url="/Tna/eNISAT/LoginTutorial.wmv" data="/Tna/eNISAT/LoginTutorial.wmv"
classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">
<param name="url" value="/Tna/eNISAT/LoginTutorial.wmv">
<param name="filename" value="/Tna/eNISAT/LoginTutorial.wmv">
<param name="autostart" value="1">
<param name="uiMode" value="full" />
<param name="autosize" value="1">
<param name="playcount" value="1">
<embed type="application/x-mplayer2" src="/Tna/eNISAT/LoginTutorial.wmv" width="100%" height="100%" autostart="true" showcontrols="true" pluginspage="http://ift.tt/10TM74A"></embed>
</object>
I know I could simply display href's to each video on a page, but I want to be able to only show the videos that a user has selected a checkbox for. I had thought of doing a SELECT query based on my users user_id, the start of my file is as follows:
<?php
session_start();
include_once 'dbconnect.php';
if(!isset($_SESSION['user']))
{
header("Location: index.php");
}
$res=mysql_query("SELECT * FROM users WHERE user_id=".$_SESSION['user']);
$userRow=mysql_fetch_array($res);
@$answersID=['user_id'];
@$Log=['Log'];
@$Worktray=['Worktray'];
@$Visual=['Visual'];
@$ChangePd=['ChangePd'];
@$Logout=['Logout'];
@$ClientSearch=['ClientSearch'];
@$StartAssessment=['StartAssessment'];
@$Finalise=['Finalise'];
@$Print=['Print'];
@$Hcn=['Hcn'];
@$Lcid=['Lcid'];
@$Soscare=['Soscare'];
@$Reassign=['Reassign'];
@$Close=['Close'];
$query="SELECT * FROM enisatanswer (Log,Worktray,Visual,ChangePd,Logout,ClientSearch,StartAssessment,Finalise,Print,Hcn,Lcid,Soscare,Reassign,Close) WHERE user_id='$answersID' VALUES
('$Log', '$Worktray','$Visual', '$ChangePd', '$Logout', '$ClientSearch','$StartAssessment', '$Finalise','$Print', '$Hcn','$Lcid', '$Soscare', '$Reassign', '$Close')";
mysql_query($query) or die (mysql_error() );
//if($query==true)
$rs = mysql_query($query);
if(!$rs) {
die("Query error:" .mysql_error( ));
}
$numTutorials = mysql_num_rows($rs);
print "The number of tutorials you selected is $$numTutorials";
I dont even think this query is right, my further code tries to echo out table contents but this isnt working and there is no way to only choose the videos for checked boxes selected that I am aware of. I do not know what my next steps should be.
My question is can anyone help me with some code that would display the results from my table WHERE the user's ID = SESSION userID, and somehow only display the hrefs which link to my html files for the selected checboxes. I hope this makes sense. Feel free to ask if you need any further information.
Thanks
Aucun commentaire:
Enregistrer un commentaire