Skip to content

Instantly share code, notes, and snippets.

View itswadesh's full-sized avatar

Swadesh Behera itswadesh

View GitHub Profile
<?php
require_once '../includes/db.php'; // The mysql database connection script
$status = '%';
if(isset($_GET['status'])){
$status = $_GET['status'];
}
$query="select ID, TASK, STATUS from tasks where status like '$status' order by status,id desc";
$result = $mysqli->query($query) or die($mysqli->error.__LINE__);
$arr = array();
//Define an angular module for our app
var app = angular.module('myApp', []);
app.controller('tasksController', function($scope, $http) {
getTask(); // Load all available tasks
function getTask(){
$http.post("ajax/getTask.php").success(function(data){
$scope.tasks = data;
});
};
<?php
require_once '../includes/db.php'; // The mysql database connection script
if(isset($_GET['task'])){
$task = $_GET['task'];
$status = "0";
$created = time();
$query="INSERT INTO tasks(task,status,created_at) VALUES ('$task', '$status', '$created')";
$result = $mysqli->query($query) or die($mysqli->error.__LINE__);
body{
font-family: 'Open Sans', sans-serif;
}
a {
color: #E1704B;
transition: color 0.5s ease;
}
a:hover{
cursor:pointer;
}
<?php
$DB_HOST = '127.0.0.1';
$DB_USER = 'root';
$DB_PASS = '';
$DB_NAME = 'angularcode_task';
$mysqli = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME);
?>
<div class="widget-box" id="recent-box" ng-controller="tasksController">
<div class="widget-header header-color-blue">
<div class="row">
<div class="col-sm-6">
<h4 class="bigger lighter">
<i class="glyphicon glyphicon-align-justify"></i>&nbsp;
TASK MANAGER
</h4>
</div>
<div class="col-sm-3">
<html ng-app="myApp">
<head>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
<link rel="stylesheet" type="text/css" href="css/taskman.css"/>
<link href="http://fonts.googleapis.com/css?family=Open+Sans:400,600,300,700" rel="stylesheet" type="text/css">
</head>
<body ng-controller="tasksController">
<div class="navbar navbar-default" id="navbar">
CREATE DATABASE IF NOT EXISTS angularcode_task;
USE angularcode_task;
--
-- Table structure for table `tasks`
--
CREATE TABLE IF NOT EXISTS `tasks` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`task` varchar(200) NOT NULL,
<?php
include('../includes/config.php');
$id = $_GET['id'];
$votes = $_GET['votes'];
$query="update posts set votes='$votes' where id='$id'";
$result = $mysqli->query($query) or die($mysqli->error.__LINE__);
// $affected = $mysqli->affected_rows;
?>
var app = angular.module('myApp',[]);
app.controller('votingCtrl', function($scope, $http) {
$http.post('ajax/getPosts.php').success(function(data){
$scope.posts = data;
});
$scope.upVote = function(post){
post.votes++;
updateVote(post.id,post.votes);
};
$scope.downVote = function(post){