THIS BLOG IS JUST FOR FREE INFORMATION,KNOWLEGES AND MORE. Here you can learn php , javascripts, bootstrap and soon.
Tuesday, April 18, 2017
Tuesday, March 28, 2017
How to make a autocomplete using jquery and php pdo with parsing json data from mysql
Here is the video tutorial for easy understanding
create mysql database autocomplete and create table autocomplete
Table structure:
id int value=12 , primary key autoincrementtitle varchar=255 ,
json.php file
<html>
<head></he
<html>
<head>
<title>tutu</title>- <link rel="stylesheet" href="js/easy-autocomplete.min.css"/>
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="js/jquery.easy-autocomplete.min.js"></script>
</head>
<body>
<h1>Auto complete plugin with php pdo and jquery</h1>- <input id="provider-json" />
<script type="text/javascript">
var options = {- url: "json.php",
- getValue: "jsondata",
list: {
match: {
enabled: true
}
}- };
$("#provider-json").easyAutocomplete(options);
</script>
</body- </html>
json.php file
<?php
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "";
$dbname = "autocomplete";
try{
$dbcon = new PDO("mysql:host=$dbhost;dbname=$dbname",$dbuser,$dbpass);
$dbcon->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}catch(PDOException $ex){
die($ex->getMessage());
}- $sqlquery = "select * from autocomplete";
$run = $dbcon->prepare($sqlquery);- $run->execute();
- $out = array();
while($row=$run->fetch(PDO::FETCH_ASSOC)) {
$out[]= array('jsondata'=>$row['title']);
}
echo json_encode($out);
?>
How can we load PHP file into DIV by jQuery?
In this tutorial, I am going to show you, How we can load .php file using jquery.
To load .php file, we simply use load() function to call php file in a div.
Here is the example how i load php file with jquery load() function
Database Name: `load`
Table structure for table `categories`
CREATE TABLE IF NOT EXISTS `categories` (`cat_id` int(100) NOT NULL,
`cat_title` varchar(500) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=latin1;
Dumping data for table `categories`
INSERT INTO `categories` (`cat_id`, `cat_title`) VALUES(3, 'What is html?'),
(4, 'What is css?'),
(5, 'What is php?\r\n'),
(10, 'What is linux?'),
(13, 'toit');
db.php
- <?Php
- $dbhost = 'localhost';
- $dbname = 'load';
- $dbuser = 'root';
- $dbpass = '';
- try{
- $dbcon = new PDO("mysql:host={$dbhost};dbname={$dbname}",$dbuser,$dbpass);
- $dbcon->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- }catch(PDOException $ex){
- die($ex->getMessage());
- }
- ?>
index.php
- <!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>onlinestudy.bramento.com</title>
- <script type="text/javascript">
- $(document).ready(function() {
- $("#results").load("getcat.php"); //using load() functions here
- });
- </script>
- </head>
- <h1> How we can load .php file using jquery.</h1>
- <div id="results"></div>
- <body>
- </body>
- </html>
getcat.php
- <?php
- require_once 'db.php';
- $stmt = $dbcon->prepare('SELECT * FROM categories');
- $stmt->execute();
- while($row=$stmt->fetch(PDO::FETCH_ASSOC))
- {
- extract($row);
- ?>
- <p> <?php echo $row['cat_title']; ?></p>
- <?php
- }
- ?>
How to Create Visitors counter by IP address in php pdo
This Tutorial is about How to Create Visitors counter by IP address in php pdo
First Create the database and name it as view and then create table
Table structure for table `visitors`
CREATE TABLE `visitors` (`id` int(11) NOT NULL,
`ip` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `visitors`
--
INSERT INTO `visitors` (`id`, `ip`) VALUES
(2, ''),
(3, ''),
(4, '::1'),
(5, '127.0.0.1');
<?Php
$dbhost = 'localhost';
$dbname = 'views';
$dbuser = 'root';
$dbpass = '';
try{
$dbcon = new PDO("mysql:host={$dbhost};dbname={$dbname}",$dbuser,$dbpass);
$dbcon->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}catch(PDOException $ex){
die($ex->getMessage());
}
?>
<?php
$ip = $_SERVER['REMOTE_ADDR'];
$stmt = $dbcon->prepare("SELECT ip FROM visitors WHERE ip= '$ip'");
$stmt->execute();
$stmt1=$stmt->rowCount();
if ($stmt1==0) {
$stmt2 = $dbcon->prepare("INSERT INTO visitors(id, ip) VALUES(NULL, '$ip')");
$stmt2->execute();
}
$stmt = $dbcon->prepare('SELECT * FROM visitors');
$stmt->execute();
while($row=$stmt->fetch(PDO::FETCH_ASSOC))
{
extract($row);
echo $row['ip'];
}
?>
How to install laravel? xampp-window-php framework
How to install laravel? xampp-window-php framework
laravel download and setup link used in the video
laravel download and setup link used in the video
Worlds Best Amazing flute played on Resham Firiri by young guys
Amazing flute played on resham firiri by Nepali young guys
Amazing flute played on resham firiri by Nepali young guys
Amazing flute played on resham firiri by Nepali young guys
Worlds Best Amazing flute played on Resham Firiri by young guys
Monday, March 27, 2017
How to integrate kcfinder-filemanager in ckeditor(CKEditor in PHP Tutorial)
How to integrate kcfinder-filemanager in ckeditor(CKEditor in PHP Tutorial)
In this video, you will know how to integrate kcfinder-filemanager in ckeditor
links for ckeditor: http://ckeditor.com/
links for kcfinder https://kcfinder.sunhater.com/integrate
How to Display Mysql Data in a Select List of Bootstrap framework With php pdo?
In this video tutorial you will know to Display Mysql Data in a Select List of Bootstrap framework With php pdo.
Bootstrap link : http://getbootstrap.com/
.php mysql pdo connection
index.php file
<?Php
$dbhost = 'localhost';
$dbname = 'selectlist';
$dbuser = 'root';
$dbpass = '';
try{- $dbcon = new PDO("mysql:host={$dbhost};dbname={$dbname}",$dbuser,$dbpass);
$dbcon->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}catch(PDOException $ex){
die($ex->getMessage());
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->- <title>Bootstrap 101 Template</title>
<!-- Bootstrap -->
<!-- Latest compiled and minified CSS -->- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
<h1>Dynamic Select List in php mysql!</h1>
<div class="col-md-4">
<div class="form-group">
<label for="sel1">Select list:</label>
<select class="form-control" id="sel1">
<?php
$sqlquery = $dbcon->prepare('SELECT * FROM selectlist ORDER BY id DESC');- $sqlquery->execute();
while($row=$sqlquery->fetch(PDO::FETCH_ASSOC))
{
extract($row)
?>- <option>
<?php
echo $row['title'];
?>
</option>
<?php
}
?>
</select>
</div>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</body>- </html>
How Can we Convert MySQL Rows into JSON Format in PHP PDO
How Can we Convert MySQL Rows into JSON Format in PHP PDO
In this video tutorial you will know How To Parse JSON With PHP
JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate.
JSON is a data exchange format between web/mobile applications.
It can easily convert data into plain text in human readable format.
Easily understand Get And Post Methods in PhP
Easily understand Get And Post Methods in PhP
Above Scripts
- <?php
- $x = 'Hello';
- echo $x;
- ?>
- <a href= "index.php?id">get</a>
- <?php
- if(isset($_GET['id']))
- {
- echo '<br>hello i got it';
- }
- ?>
- <form action="index.php" method="post">
- <input type="submit" value='post' name="submit">
- </form>
- <?php
- if(isset($_POST['submit']))
- {
- echo '<br>hello i got it';
- }
- ?>
How To Upload And Display Images And Text Together Using PHP PDO.
This is just a simple techniques to upload images as well as add text in PHP PDO. This is soo easy to do it.
To do this first just create database uploads and then create table as posts and then create columns post_id ,image_title and post_image as integer,varchar,varchar respectively..
First create uploads folder for images saving on it and displaying on your browser through server.
Now Lets Begin, Create index.php file.
and create form on index.php as like this
- <form method="post" action="upload.php" enctype="multipart/form-data">
- <table class="table1">
- <tr>
- <td><label style="color:#3a87ad; font-size:18px;">Image Title</label></td>
- <td width="30"></td>
- <td><input type="text" name="image_title" placeholder="image_title" required /></td>
- </tr>
- <tr>
- <td><label style="color:#3a87ad; font-size:18px;">Select Image</label></td>
- <td width="30"></td>
- <td><input type="file" name="image"></td>
- </tr>
- </table>
- <button type="submit" name="Submit" class="btn btn-primary">upload</button>
- </form>
Now lets jump on php pdo scripts to proceed for database connection first.
create new php file again and save it as db.php and paste these scripts on this file.
- <?php
- //this scripts connect to your database
- $db_host = "localhost";
- $db_name = "uploads";
- $db_user = "root";
- $db_pass = "";
- try{
- $db_con = new PDO("mysql:host={$db_host};dbname={$db_name}",$db_user,$db_pass);
- $db_con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- }
- catch(PDOException $e){
- echo $e->getMessage();
- }
- ?>
And Again lets create upload.php where our form gonna submited on this page and proceed for uploading and adding text on uploads folder and mysql table that we have created.
Add some scripts for uploading now on upload.php
- <?php
- include('db.php');
- if(isset($_POST['Submit']))
- {
- $post_image=$_FILES["image"]["name"];
- $image_title=$_POST['image_title'];
- }
- try{
- move_uploaded_file($_FILES["image"]["tmp_name"],"uploads/" . $_FILES["image"]["name"]);
- //sql query for insertion
- $stmt = $db_con->prepare("INSERT INTO posts(image_title,post_image) VALUES( :image_title, :post_image)");
- $stmt->bindParam(":image_title", $image_title);
- $stmt->bindParam(":post_image", $post_image);
- if($stmt->execute())
- {
- echo "<script>alert('Successfully Added..')</script>";
- echo "<script>window.open('index.php','_self')</script>";
- }
- else{
- echo "Query Problem";
- }
- }
- catch(PDOException $e){
- echo $e->getMessage();
- }
- ?>
And last to display uploaded images from the uploads folder and text or image title from the database table posts just copy and paste thes scripts on your index.php file .
- <?php
- include('db.php');
- //query for selecting database table
- $results = $db_con->prepare("SELECT * FROM posts ORDER BY post_id");
- $results->execute();
- // this while statement displays rows of database table
- while($row=$results->fetch(PDO::FETCH_ASSOC))
- {
- extract($row);
- ?>
- <div class="col-sm-4">
- <div class="thumbnail">
- <h4 style="color:red" align="center"><?php echo $row['image_title']; ?></h4>
- <img src="uploads/<?php echo $row['post_image']; ?>" class="img-rounded" alt="image" style="width:200px" height="200px;">
- </div>
- </div>
- <?php
- }
- ?>
full index.php file
- <!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>Bramento.com</title>
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" >
- <script src="../js/jquery.min.js"></script>
- <script src="../bootstrap/bootstrap.min.js"></script>
- </head>
- <body>
- <div class="container">
- <div class="thumbnail">
- <h3 style="color:#F06"> How to upload images with text in php pdo</h3>
- <form method="post" action="upload.php" enctype="multipart/form-data">
- <table class="table1">
- <tr>
- <td><label style="color:#3a87ad; font-size:18px;">Image Title</label></td>
- <td width="30"></td>
- <td><input type="text" name="image_title" placeholder="image_title" required /></td>
- </tr>
- <tr>
- <td><label style="color:#3a87ad; font-size:18px;">Select Image</label></td>
- <td width="30"></td>
- <td><input type="file" name="image"></td>
- </tr>
- </table>
- <button type="submit" name="Submit" class="btn btn-primary">upload</button>
- </form>
- </div>
- <?php
- include('db.php');
- //query for selecting database table
- $results = $db_con->prepare("SELECT * FROM posts ORDER BY post_id");
- $results->execute();
- // this while statement displays rows of database table
- while($row=$results->fetch(PDO::FETCH_ASSOC))
- {
- extract($row);
- ?>
- <div class="col-sm-4">
- <div class="thumbnail">
- <h4 style="color:red" align="center"><?php echo $row['image_title']; ?></h4>
- <img src="uploads/<?php echo $row['post_image']; ?>" class="img-rounded" alt="image" style="width:200px" height="200px;">
- </div>
- </div>
- <?php
- }
- ?>
- </div>
- </body>
- </html>
full upload.php file
<?php
include('db.php');
if(isset($_POST['Submit']))
{
$post_image=$_FILES["image"]["name"];
$image_title=$_POST['image_title'];
}
try{
move_uploaded_file($_FILES["image"]["tmp_name"],"uploads/" . $_FILES["image"]["name"]);
$stmt = $db_con->prepare("INSERT INTO posts(image_title,post_image) VALUES( :image_title, :post_image)");
}
try{
move_uploaded_file($_FILES["image"]["tmp_name"],"uploads/" . $_FILES["image"]["name"]);
$stmt = $db_con->prepare("INSERT INTO posts(image_title,post_image) VALUES( :image_title, :post_image)");
$stmt->bindParam(":image_title", $image_title);
$stmt->bindParam(":post_image", $post_image);
$stmt->bindParam(":post_image", $post_image);
if($stmt->execute())
{
echo "<script>alert('Successfully Added..')</script>";
echo "<script>window.open('index.php','_self')</script>";
}
else{
echo "Query Problem";
}
}
catch(PDOException $e){
echo $e->getMessage();
}
?>
{
echo "<script>alert('Successfully Added..')</script>";
echo "<script>window.open('index.php','_self')</script>";
}
else{
echo "Query Problem";
}
}
catch(PDOException $e){
echo $e->getMessage();
}
?>
Full db.php file
- <?php
- date_default_timezone_set("Asia/Kathmandu");
- $db_host = "localhost";
- $db_name = "uploads";
- $db_user = "root";
- $db_pass = "";
- try{
- $db_con = new PDO("mysql:host={$db_host};dbname={$db_name}",$db_user,$db_pass);
- $db_con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- }
- catch(PDOException $e){
- echo $e->getMessage();
- }
- ?>
How to use facebook comment ,like,share buttons or plugins dynamically?
Hello Guys!
This tutorial is about plugins of facebook. As we all know that facebook have made us soo easy to use its share,like button and coment plugin etc for developer.
Any one can use this by copying soo easily bt its some tricky too use it dynamically.
Today, in this tutorial , i am going to show you how I have used it dynamically.
First go to this website of facebook for developer to use its plugins and like button , share,send etc.facebook for developer.
Now, just grab the codes from there of coment,share , like plugins and paste it where to in your website.
I have used it like this giving link on 9,12 line as like this using link id "http://onlinestudy.bramento.com/pages/detail.php?post_id=<?php echo($row['post_id']); ?>
- <div id="fb-root"></div>
- <script>(function(d, s, id) {
- var js, fjs = d.getElementsByTagName(s)[0];
- if (d.getElementById(id)) return;
- js = d.createElement(s); js.id = id;
- js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.8";
- fjs.parentNode.insertBefore(js, fjs);
- }(document, 'script', 'facebook-jssdk'));</script>
- <div class="fb-like" data-href="http://onlinestudy.bramento.com/pages/detail.php?post_id=<?php echo($row['post_id']); ?>" data-layout="button_count" data-action="like" data-size="large" data-show-faces="true"></div> <div class="fb-send" data-href="http://onlinestudy.bramento.com/pages/detail.php?post_id=<?php echo($row['post_id']); ?>"></div>
- <br />
- <div class="fb-comments" data-href="http://onlinestudy.bramento.com/pages/detail.php?post_id=<?php echo($row['post_id']); ?>" data-numposts="5"></div>
Vue.js tutorial. Reverse in Vue.js, v-on directive
Vue.js tutorial. Reverse in Vue.js, v-on directive
In this tutorial you will learn to know the v-on directive to attach event listeners
Subscribe to:
Posts (Atom)

