从多个CheckBox中选择不同类别的Bootstrap选项卡

时间:2017-12-11 12:41:31

标签: php jquery twitter-bootstrap

我正在开展一个CBT网络应用程序项目。我有一个数据库,根据类别不同,有不同的问题。 用户登录后,下一页是dash.php,用户必须选择至少4个主题(课程),然后单击“提交”以开始测试。 下一页名为questions.php页面,这些问题将在一个窗口(界面)的bootstrap选项卡中打开。

这是我的代码

            SQL For Database

            CREATE TABLE IF NOT EXISTS `users` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `category_id` int(11) NOT NULL,
            `user_name` varchar(60) NOT NULL,
            `reg_no` varchar(50) NOT NULL,
            PRIMARY KEY (`id`)
            ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=17 ;

            --
            -- Dumping data for table `users`
            --

            INSERT INTO `users` (`id`, `category_id`, `user_name`, `reg_no`) VALUES
            (1, 1, 'DANIEL FLORENCE NSE', '16/STV/033'),
            (2, 1, 'DOLTINO MARY BASSEY', '16/STV/034'),
            (3, 1, 'EDET ESTHER EFFIONG', '16/STV/035'),
            (4, 1, 'EFFIOM OFFIONG CHARLES ', '16/STV/036'),
            (5, 1, 'EFFIONG QUEENETH DOMINC ', '16/STV/037'),
            (6, 1, 'EFFIONG JOANNA OKON', '16/STV/038'),
            (7, 1, 'EJUKWA FELICITY EJOGHA', '16/STV/039'),
            (8, 1, 'EKONG THELMA MFON', '16/STV/040'),
            (9, 1, 'EKPE PRAISE WILFRED', '16/STV/041'),
            (10, 1, 'ETTAH GENEVIEVE HODO', '16/STV/042'),
            (11, 1, 'EYO ESTHER RICHARD', '16/STV/043');



            CREATE TABLE IF NOT EXISTS `questions` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `question_name` text NOT NULL,
            `answer1` varchar(250) NOT NULL,
            `answer2` varchar(250) NOT NULL,
            `answer3` varchar(250) NOT NULL,
            `answer4` varchar(250) NOT NULL,
            `answer` varchar(250) NOT NULL,
            `category_id` int(11) NOT NULL,
            PRIMARY KEY (`id`)
            ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=21 ;

            --
            -- Dumping data for table `questions`
            --

            INSERT INTO `questions` (`id`, `question_name`, `answer1`, `answer2`, `answer3`, `answer4`, `answer`, `category_id`) VALUES
            (1, 'Where did India play its 1st one day international match?', 'Lords', 'Headingley', 'Taunton', 'The Oval', '2', 1),
            (2, 'Who was the 1st ODI captain for India?\r\n', 'Ajit Wadekar ', 'Bishen Singh Bedi', 'Nawab Pataudi', 'Vinoo Mankad ', '1', 1),
            (3, 'Who has made the Fastest Test century in Test Cricket ?\r\n\r\n\r\n\r\n', 'Sachin Tendulkar', ' Sahid Afridi', ' Virender Sehwag', 'Vivian Richards', '4', 1),
            (4, 'Which Bowler had the Best figures in a Test Match ?\r\n\r\n\r\n\r\n\r\n', 'Muttiah Muralitharan', 'Bob Massie', 'Jim Laker', 'George Lohmann', '3', 1),
            (5, 'Which team has the Largest successful run chase record in ODIs ?\r\n\r\n\r\n\r\n\r\n', 'England', 'South Africa', 'Australia', 'India', '2', 2),
            (6, 'What does HTML stand for?\r\n\r\n  \r\n    \r\n    ', 'Hyper Text Markup Language', 'Hyperlinks and Text Markup Language', 'Home Tool Markup Language', 'Highly Text Markup Language', '1', 1),
            (7, 'Who is making the Web standards?\r\n\r\n   \r\n    \r\n    \r\n    \r\n', 'Microsoft', 'Google', 'The World Wide Web Consortium', 'Mozilla', '3', 2),
            (8, 'What is the correct HTML for creating a hyperlink?\r\n\r\n \r\n    \r\n    \r\n    ', '<a name="http://maxil.net">Smart Tutorials</a>', '<a>http://maxil.net</a>', '<a url="http://maxil.net">Smart Tutorials</a>', '<a href="http://maxil.net">Smart Tutorials</a>', '4', 1),
            (9, 'What is the HTML element to bold a text?\r\n\r\n\r\n\r\n\r\n', '<b>', '<bold>', '<wide>', '<big>', '1', 2),
            (10, 'What is the HTML tag for a link?\r\n\r\n\r\n\r\n\r\n', '<link>', '<ref>', '<a>', '<hper>', '3', 2),
            (11, 'What does CSS stand for?\r\n\r\n  \r\n    \r\n    \r\n    ', 'Creative Style Sheets', 'Colorful Style Sheets', 'Computer Style Sheets', 'Cascading Style Sheets', '4', 3),
            (12, 'Where in an HTML document is the correct place to refer to an external style sheet?\r\n\r\n   \r\n    \r\n    \r\n    ', 'In the <body> section ', 'At the end of the document', 'At the top of the document', 'In the <head> section ', '4', 1),
            (13, 'Which HTML tag is used to define an internal style sheet?\r\n\r\n \r\n    \r\n    ', '<script>', '<css>', '<style>', '<link>', '3', 3),
            (14, 'Which is the correct CSS syntax?\r\n\r\n  \r\n    \r\n    \r\n    ', 'body:color=black;', '{body;color:black;}', 'body {color: black;}', '{body:color=black;}', '3', 3),
            (15, 'Which property is used to change the background color?\r\n\r\n    \r\n    \r\n    ', 'background-color', 'color', 'bgcolor', 'bg-color', '1', 4),
            (16, 'What does PHP stand for?\r\n\r\n  \r\n    \r\n    ', ' PHP: Hypertext Preprocessor', 'Personal Hypertext Processor', 'Personal Home Page', 'Private Home Page', '1', 4),
            (17, 'PHP server scripts are surrounded by delimiters, which?\r\n\r\n   \r\n    \r\n    \r\n    ', '<?php>...</?>', '<?php ... ?>', '<script>...</script>', '<&>...</&>', '2', 4),
            (18, 'How do you write "Hello World" in PHP\r\n\r\n \r\n    \r\n    ', '"Hello World"', 'echo "Hello World"', 'Document.Write("Hello World");', 'print_f("Hello World");', '2', 1),
            (19, ' Which of the following is the way to create comments in PHP?\r\n\r\n\r\n \r\n    \r\n    ', '// commented code to end of line', '/* commented code here */', '# commented code to end of line', 'all of the above - correct', '4', 4),
            (20, 'What is the correct way to end a PHP statement?\r\n\r\n   \r\n    \r\n    \r\n    ', '</php>', '.', ';', 'New line', '3', 1);

    ------------------------------------------------------------------

的config.php

            dash.php                

            <?php
            session_start();
            ?>

            <?php 
            require 'config.php';
            $category= "";
            if(!empty($_POST['name'])){
            $name=$_POST['name'];

            $_SESSION['name']= $name;
            $_SESSION['id'] = mysql_insert_id();
            }
            if(!empty($_SESSION['name'])){
            ?>
            <!DOCTYPE html>
            <html>
            <head>
            <title>ExamsLTE</title>
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <!-- Bootstrap -->
            <link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
            <link href="css/style.css" rel="stylesheet" media="screen">

            <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
            <!--[if lt IE 9]>
            <script src="../../assets/js/html5shiv.js"></script>
            <script src="../../assets/js/respond.min.js"></script>
            <![endif]-->

            <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
            <script src="js/jquery-1.10.2.min.js"></script>
            <!-- Include all compiled plugins (below), or include individual files as needed -->
            <script src="js/bootstrap.min.js"></script>
            <script src="js/jquery.validate.min.js"></script>
            <script src="js/countdown.js"></script>
            <style>
            .container {
            margin-top: 110px;
            }
            .error {
            color: #B94A48;
            }
            .form-horizontal {
            margin-bottom: 0px;
            }
            .hide{display: none;}
            </style>
            </head>
            <body>
            <header>
            <p class="text-center">
            Welcome : <?php if(!empty($_SESSION['name'])){echo $_SESSION['name'];}?>
            </p>
            </header>


            <div class="container question">
            <div class="col-xs-12 col-sm-8 col-md-8 col-xs-offset-4 col-sm-offset-3 col-md-offset-3">
            <p>

            </p>
            <hr>
            <form class="form-horizontal" role="form" id='login' method="post" action="questions.php">
            <div class="checked-group">

            <input type="checkbox" value="1" name="mts">Mathematics

            <br />

            <input type="checkbox" value="2" name="eng">English Language

            <br />

            <input type="checkbox" value="3" name="bio"> Biology

            <br />

            <input type="checkbox" value="4" name="phy">Physics

            <br />

            <input type="checkbox" value="5" name="chm">Chemistry

            <br />

            <input type="checkbox" value="6" name="agc">Agricultural Science

            <br />

            <input type="checkbox" value="7" name="ecs">Economics

            <br />

            <input type="checkbox" value="8" name="cmc">Commerce

            <br />

            <input type="checkbox" value="9" name="com">Computer Studies

            <br>
            <button class="btn btn-success btn-block" type="submit"><!-- 0n click go to Quest -->
            Submit
            </button>

            </div>

            </form>
            </div>
            </div>
            <footer>
            <p class="text-center" id="foot">
            &copy; <a href="#" target="_blank">CSB ICT</a> 2014 - 2018
            </p>
            </footer>




            </body>
            </html>
            <?php }else{

            header( 'Location: index.php' ) ;

            }
            ?>

This is example of what i want on the questions.php page

0 个答案:

没有答案