Sunday, 19 May 2019

How to create quiz pages on a Blogger blog


1. What is the answer to this question?






2. What is the answer to this question?




3. What is the answer to this question?




4. What is the answer to this question?




5. What is the answer to this question?




6. What is the answer to this question?




7. What is the answer to this question?




8. What is the answer to this question?




9. What is the answer to this question?




10. What is the answer to this question?





Show me the answers!
Question 1: The correct answer is the Answer 1.
Question 2: The correct answer is Answer 2.
Question 3: The correct answer is Answer 3.
Question 4: The correct answer is Answer 4.
Question 5: The correct answer is Answer 1.
Question 6: The correct answer is Answer 2.
Question 7: The correct answer is Answer 3.
Question 8: The correct answer is Answer 4.
Question 9: The correct answer is Answer 1.
Question 10: The correct answer is Answer 2.
You answered them all right!

Monday, 22 April 2019

simple pagination using php code

simple pagination using php code



pagination.php

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" id="font-awesome-style-css" href="http://phpflow.com/code/css/bootstrap3.min.css" type="text/css" media="all">
<!-- jQuery -->
<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js"></script>
<script type="text/javascript" charset="utf8" src="select2.js"></script>
<link rel="stylesheet" type="text/css" href="select2.css"> 
<title>phpflow.com : Source code of simaple pagination</title>
</head>

<body>
<div><h3>Source code : PHP simaple pagination</h1></div>
<div>
<link href="bootstrap.css" rel="stylesheet">  
<?php  
$dbhost = 'localhost';  
$dbuser = 'root';  
$dbpass = "";  
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');  
$dbname = 'test';  
$connection = mysql_select_db($dbname); 
  
$limit = 2;  
if (isset($_GET["page"])) { $page  = $_GET["page"]; } else { $page=1; };  
$start_from = ($page-1) * $limit;  
  
$sql = "SELECT * FROM posts ORDER BY title ASC LIMIT $start_from, $limit";  
$rs_result = mysql_query ($sql);  
?>  
<table class="table table-bordered table-striped">  
<thead>  
<tr>  
<th>title</th>  
<th>body</th>  
</tr>  
</thead>  
<tbody>  
<?php  
while ($row = mysql_fetch_assoc($rs_result)) {  
?>  
            <tr>  
            <td><? echo $row["title"]; ?></td>  
            <td><? echo $row["body"]; ?></td>  
            </tr>  
<?php  
};  
?>  
</tbody>  
</table>  
<?php  
$sql = "SELECT COUNT(id) FROM posts";  
$rs_result = mysql_query($sql);  
$row = mysql_fetch_row($rs_result);  
$total_records = $row[0];  
$total_pages = ceil($total_records / $limit);  
$pagLink = "<ul class='pagination'>";  
for ($i=1; $i<=$total_pages; $i++) {  
             $pagLink .= "<li><a href='pagination.php?page=".$i."'>".$i."</a></li>";  
};  
echo $pagLink . "</ul>";  
?>  
</div>
</body>
<script>
jQuery(document).ready(function() {
jQuery("#extId").select2({
                width: 'element',
                matcher: function(term, text) {
                    return text === 'Add New Number' || $.fn.select2.defaults.matcher.apply(this, arguments);
                },
                sortResults: function(results) {
                    if (results.length > 1) results.pop();
                    return results;
                }
});
    });
</script>


posts.sql for database




--
-- Database: `test`
--

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

--
-- Table structure for table `posts`
--

CREATE TABLE IF NOT EXISTS `posts` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(255) NOT NULL,
  `body` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;

--
-- Dumping data for table `posts`
--


INSERT INTO `posts` (`id`, `title`, `body`) VALUES

(1, 'title1', 'body1'),
(2, 'title2', 'body'),
(3, 'title3', 'body3'),
(4, 'title4', 'body4');

responsive html email template code


responsive html email template code



<!DOCTYPE html>

<html>
    <head>
   
        <title>Responsive html email</title>
       
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
       
        <style type="text/css">
            /* Defaults */
            h1 { font-size: 28px;}
            h2 { font-size: 24px; }
            .text-center { text-align: center;}

            /* Apple specific fix */
            @media screen and (min-width: 601px) {
                .container {width: 600px!important;}
            }
        </style>

    </head>


    <body bgcolor="#f4f4f4" style="font-family: sans-serif; color: #333333; line-height: 150%; font-size: 16px;">
        <!--[if (gte mso 9)|(IE)]>
        <table width="600" align="center" cellpadding="0" cellspacing="0" border="0">
            <tr>
                <td>
        <![endif]-->

                    <!-- START : EMAIL CONTENT -->
                    <table bgcolor="#ffffff" class="container" width="100%" cellpadding="0" cellspacing="0" style="max-width: 600px; margin:auto;">

                        <!-- START : 1 COLUMN -->
                        <tr>
                            <td class="text-center">
                                <h1>Email header</h1>
                            </td>
                        </tr>
                        <!-- END : 1 COLUMN -->

                        <tr>
                            <td bgcolor="#f8f8f8" style="padding: 20px;">
                                Lorem ipsum dolor sit amet, usu ut legimus voluptatum. Mel ei corrumpit liberavisse, ex vix tollit causae. Ea est debitis recusabo, at latine detracto dissentiet nec, id ius quidam molestie. Sit in aeterno offendit reformidans. Hinc vituperatoribus ne qui, eam ne iusto alterum. Eos qualisque conceptam instructior ut, cu habeo voluptaria vis. Nec at sanctus indoctum sapientem, vim agam minim an.
                            </td>
                        </tr>

                        <tr>
                            <td style="font-style: italic; text-align: center;">
                                <h2>"Lorem ipsum dolor sit amet, usu ut legimus voluptatum"</h2>
                            </td>
                        </tr>

                        <tr>
                            <td style="padding: 0 20px;">
                                Lorem ipsum dolor sit amet, usu ut legimus voluptatum. Mel ei corrumpit liberavisse, ex vix tollit causae. Ea est debitis recusabo, at latine detracto dissentiet nec, id ius quidam molestie.
                            </td>
                        </tr>

                        <!-- START : 2 COLUMNS -->
                        <tr>

                            <td style="text-align: center; vertical-align: top; font-size: 0; padding: 10px;">
                                <!--[if (gte mso 9)|(IE)]>
                                <table width="100%" align="center" cellpadding="0" cellspacing="0" border="0">
                                    <tr>
                                        <td>

                                <![endif]-->
                                            <div style="width: 280px; display: inline-block; vertical-align: top;">
                                                <table width="100%">
                                                    <tr>
                                                        <td style="font-size: 16px;">Column 1<br /><img src="http://placehold.it/260x260"></td>
                                                    </tr>
                                                </table>
                                            </div>
                                <!--[if (gte mso 9)|(IE)]>
                                        </td>
                                        <td>
                                <![endif]-->
                                            <div style="width: 280px; display: inline-block; vertical-align: top;">
                                                <table width="100%">
                                                    <tr>
                                                        <td style="font-size: 16px;">Column 2<br /><img src="http://placehold.it/260x260"></td>
                                                    </tr>
                                                </table>
                                            </div>
                                <!--[if (gte mso 9)|(IE)]>
                                        </td>
                                    </tr>
                                </table>
                                <![endif]-->
                            </td>
                        </tr>
                        <!-- END : 2 COLUMNS -->

                        <!-- START : 1 column bottom content -->
                        <tr>
                            <td style="padding: 0 20px 20px;">
                                Lorem ipsum dolor sit amet, usu ut legimus voluptatum. Mel ei corrumpit liberavisse, ex vix tollit causae. Ea est debitis recusabo, at latine detracto dissentiet nec, id ius quidam molestie.
                            </td>
                        </tr>
                        <!-- END : 1 column bottom content -->


                    </table>

                    <!-- START : Footer -->
                    <table width="100%" style="margin: auto; max-width: 600px;">
                        <tr>
                            <td style="text-align: center;">
                                <p><a href="#">Unsubscribe</a><p>
                            </td>
                        </tr>
                    </table>
                    <!-- END : Footer -->

        <!--[if (gte mso 9)|(IE)]>
                </td>
            </tr>

        </table>
        <![endif]-->

    </body>
</html>

dynamic textbox in php codeing




index.php




<?php

if(!empty($_POST["save"])) {
$conn = mysql_connect("localhost","root","");
mysql_select_db("examples",$conn);
$itemCount = count($_POST["item_name"]);
$itemValues=0;
$query = "INSERT INTO item (item_name,item_price) VALUES ";
$queryValue = "";
for($i=0;$i<$itemCount;$i++) {
if(!empty($_POST["item_name"][$i]) || !empty($_POST["item_price"][$i])) {
$itemValues++;
if($queryValue!="") {
$queryValue .= ",";
}
$queryValue .= "('" . $_POST["item_name"][$i] . "', '" . $_POST["item_price"][$i] . "')";
}
}
$sql = $query.$queryValue;
if($itemValues!=0) {
$result = mysql_query($sql);
if(!empty($result)) $message = "Added Successfully.";
}
}
?>

<HTML>
<HEAD>
<TITLE>Dynamic Textbox</TITLE>
<LINK href="style.css" rel="stylesheet" type="text/css" />
<SCRIPT src="http://code.jquery.com/jquery-2.1.1.js"></SCRIPT>
<SCRIPT>
function addMore() {
$("<DIV>").load("input.php", function() {
$("#product").append($(this).html());
});
}
function deleteRow() {
$('DIV.product-item').each(function(index, item){
jQuery(':checkbox', this).each(function () {
            if ($(this).is(':checked')) {
$(item).remove();
            }
        });
});
}
</SCRIPT>
</HEAD>
<BODY>
<FORM name="frmProduct" method="post" action="">
<DIV id="outer">
<DIV id="header">
<DIV class="float-left">&nbsp;</DIV>
<DIV class="float-left col-heading">Item Name</DIV>
<DIV class="float-left col-heading">Item Price</DIV>
</DIV>
<DIV id="product">
<?php require_once("input.php") ?>
</DIV>
<DIV class="btn-action float-clear">
<input type="button" name="add_item" value="Add More" onClick="addMore();" />
<input type="button" name="del_item" value="Delete" onClick="deleteRow();" />
<span class="success"><?php if(isset($message)) { echo $message; }?></span>
</DIV>
<DIV class="footer">
<input type="submit" name="save" value="Save" />
</DIV>
</DIV>
</form>
</BODY>
</HTML>



input.php



<DIV class="product-item float-clear" style="clear:both;">
<DIV class="float-left"><input type="checkbox" name="item_index[]" /></DIV>
<DIV class="float-left"><input type="text" name="item_name[]" /></DIV>
<DIV class="float-left"><input type="text" name="item_price[]" /></DIV>
</DIV>




style.css



body{font-family: "Helvetica Neue", HelveticaNeue, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #CCCCCC;}
.float-clear{clear:both;}
.float-left{float:left;}
#outer {margin: 0 auto;width: 50%;border-top: #333 2px solid;background-color: #FFFFFF;}
.product-item input[type="text"] {padding: 5px;border:#ccc 1px solid;border-radius:4px;margin: 0px 10px;}
.product-item input[type="checkbox"] {margin: 10px;}
#header div{padding: 20px 5px 15px;margin: 0px 10px;}
.col-heading{width:150px;font-size:16px;font-weight:bold;}
.footer{padding:10px; background:#333;margin-top:20px;}
.btn-action{padding:10px;}
.btn-action input[type="button"]{padding:5px; border:#CCCCCC 1px solid; border-radius: 4px;}
input[type="submit"]{padding:5px 20px; border:#000000 1px solid; border-radius: 4px; background-color:#09f;color:#fff;}
.success{color:#66CC00;padding: 5px; font-weight:bold;}


advanced-search-using php coding

<?php
$conn = mysqli_connect("localhost", "root", "", "blog_samples");
$with_any_one_of = "";
$with_the_exact_of = "";
$without = "";
$starts_with = "";
$search_in = "";
$advance_search_submit = "";

$queryCondition = "";
if(!empty($_POST["search"])) {
$advance_search_submit = $_POST["advance_search_submit"];
foreach($_POST["search"] as $k=>$v){
if(!empty($v)) {


$queryCases = array("with_any_one_of","with_the_exact_of","without","starts_with");
if(in_array($k,$queryCases)) {
if(!empty($queryCondition)) {
$queryCondition .= " AND ";
} else {
$queryCondition .= " WHERE ";
}
}
switch($k) {
case "with_any_one_of":
$with_any_one_of = $v;
$wordsAry = explode(" ", $v);
$wordsCount = count($wordsAry);
for($i=0;$i<$wordsCount;$i++) {
if(!empty($_POST["search"]["search_in"])) {
$queryCondition .= $_POST["search"]["search_in"] . " LIKE '%" . $wordsAry[$i] . "%'";
} else {
$queryCondition .= "title LIKE '" . $wordsAry[$i] . "%' OR description LIKE '" . $wordsAry[$i] . "%'";
}
if($i!=$wordsCount-1) {
$queryCondition .= " OR ";
}
}
break;
case "with_the_exact_of":
$with_the_exact_of = $v;
if(!empty($_POST["search"]["search_in"])) {
$queryCondition .= $_POST["search"]["search_in"] . " LIKE '%" . $v . "%'";
} else {
$queryCondition .= "title LIKE '%" . $v . "%' OR description LIKE '%" . $v . "%'";
}
break;
case "without":
$without = $v;
if(!empty($_POST["search"]["search_in"])) {
$queryCondition .= $_POST["search"]["search_in"] . " NOT LIKE '%" . $v . "%'";
} else {
$queryCondition .= "title NOT LIKE '%" . $v . "%' AND description NOT LIKE '%" . $v . "%'";
}
break;
case "starts_with":
$starts_with = $v;
if(!empty($_POST["search"]["search_in"])) {
$queryCondition .= $_POST["search"]["search_in"] . " LIKE '" . $v . "%'";
} else {
$queryCondition .= "title LIKE '" . $v . "%' OR description LIKE '" . $v . "%'";
}
break;
case "search_in":
$search_in = $_POST["search"]["search_in"];
break;
}
}
}
}
$orderby = " ORDER BY id desc";
$sql = "SELECT * FROM links " . $queryCondition;
$result = mysqli_query($conn,$sql);

?>
<html>
<head>
<title>Advanced Search using PHP</title>
<style>
body{
width: 600px;
font-family: "Segoe UI",Optima,Helvetica,Arial,sans-serif;
line-height: 25px;
}
.search-box {
padding: 30px;
background-color:#C8EEFD;
}
.search-label{
margin:2px;
}
.demoInputBox {   
padding: 10px;
border: 0;
border-radius: 4px;
margin: 0px 5px 15px;
width: 250px;
}
.btnSearch{   
padding: 10px;
background: #84D2A7;
border: 0;
border-radius: 4px;

margin: 0px 5px;
color: #FFF;
width: 150px;
}
#advance_search_link {
color: #001FFF;
cursor: pointer;
}
.result-description{
margin: 5px 0px 15px;
}
</style>
<script>
function showHideAdvanceSearch() {
if(document.getElementById("advanced-search-box").style.display=="none") {
document.getElementById("advanced-search-box").style.display = "block";
document.getElementById("advance_search_submit").value= "1";
} else {
document.getElementById("advanced-search-box").style.display = "none";
document.getElementById("with_the_exact_of").value= "";
document.getElementById("without").value= "";
document.getElementById("starts_with").value= "";
document.getElementById("search_in").value= "";
document.getElementById("advance_search_submit").value= "";
}
}
</script>
</head>
<body>
<h2>Advanced Search using PHP</h2>
    <div>     
<form name="frmSearch" method="post" action="index.php">
<input type="hidden" id="advance_search_submit" name="advance_search_submit" value="<?php echo $advance_search_submit; ?>">
<div class="search-box">
<label class="search-label">With Any One of the Words:</label>
<div>
<input type="text" name="search[with_any_one_of]" class="demoInputBox" value="<?php echo $with_any_one_of; ?>" />
<span id="advance_search_link" onClick="showHideAdvanceSearch()">Advance Search</span>
</div>
<div id="advanced-search-box" <?php if(empty($advance_search_submit)) { ?>style="display:none;"<?php } ?>>
<label class="search-label">With the Exact String:</label>
<div>
<input type="text" name="search[with_the_exact_of]" id="with_the_exact_of" class="demoInputBox" value="<?php echo $with_the_exact_of; ?>" />
</div>
<label class="search-label">Without:</label>
<div>
<input type="text" name="search[without]" id="without" class="demoInputBox" value="<?php echo $without; ?>" />
</div>
<label class="search-label">Starts With:</label>
<div>
<input type="text" name="search[starts_with]" id="starts_with" class="demoInputBox" value="<?php echo $starts_with; ?>" />
</div>
<label class="search-label">Search Keywords in:</label>
<div>
<select name="search[search_in]" id="search_in" class="demoInputBox">
<option value="">Select Column</option>
<option value="title" <?php if($search_in=="title") { echo "selected"; } ?>>Title</option>
<option value="description" <?php if($search_in=="description") { echo "selected"; } ?>>Description</option>
</select>
</div>
</div>

<div>
<input type="submit" name="go" class="btnSearch" value="Search">
</div>
</div>
</form>
<?php while($row = mysqli_fetch_assoc($result)) { ?>
<div>
<div><strong><?php echo $row["title"]; ?></strong></div>
<div class="result-description"><?php echo $row["description"]; ?></div>
</div>
<?php } ?>
</div>
</body>
</html>