Programmers wa kijiji, A simple "app" ya kujua saa inapotelea wapi

[ATTACH=full]92204[/ATTACH]
Elders, nimekuwa nikitumia hii kumanage muda. Nadhani kuna mtu itasaidia
[SPOILER=“index.php”]

[CODE]<?php //setup date_default_timezone_set('Africa/Nairobi'); $con = mysqli_connect("localhost", "root","", "tracker") or die (mysqli_error()); ?>

Setting things up body{ background-color:#eaece9; } .day { color:#5a5a5a; margin-top: 100px; } .time { font-size: 120px; line-height: 0.8; } .newtask { color:#666666; background-color:inherit; margin-top:50px; border: 0px; border-bottom: 30px; border-bottom-style: solid; border-bottom-width: 2px; width:20% ; text-align:center; font-size:40px; } ul{ width:400px;
        padding-left:0px;
        }
  #alltasks{
    position:absolute;
            bottom:0px;
  }
        .line{
            position:absolute;
            top:10px;
            width:100%;
            background-color:#8df1d5;
            height:10px;
        }

.big-dot{
width: 15px;
height: 15px;
background-color: #8df1d5;
margin: 0 auto;
position: relative;
display: inline-block;
border-radius: 50%;

}

Saturday

00:00

What task are you starting?

<?php echo '
    ';
$q9 = "SELECT task FROM tasks WHERE time_elapsed =''";
$r9 = mysqli_query($con,$q9);
while ($item2 = mysqli_fetch_assoc($r9)) {
  ?>
  <li><?php echo $item2['task'] ?><span class="pull-right"><span class="big-dot"></span></span></li>

<?php }

$q7 = "SELECT task, time_elapsed FROM tasks WHERE time_elapsed !='' ORDER BY start_time DESC ";
$q7.="LIMIT 5";
$r7 = mysqli_query($con,$q7);
while ($item = mysqli_fetch_assoc($r7)) {
  ?>
  <li><?php echo $item['task'] ?><span class="pull-right"><?php echo $item['time_elapsed'] ?></span></li>

<?php }
echo '</ul>';
?>

</div>
</body>
<script>
$(".newtask").keypress(function(e){
    if (e.which == 13){

        var newTask = $('#newtask').val();
  $('#newtask').val('');
    $.ajax({
        url: "tasks.php",
        type: "POST",
        data:{ task : newTask},
        dataType :  "html",   //expect html to be returned
    success: function(response){
        $("#alltasks").html(response);
        //alert(response);
        keepFading();
    }
    });


    } // if e.which
}); //newtask keypress


</script>
[/CODE] [/SPOILER] [SPOILER="time-taken.php //updates "] [CODE]<?php

//setup
date_default_timezone_set(‘Africa/Nairobi’);
$con = mysqli_connect(“localhost”, “root”,“”, “tracker”) or die (mysqli_error());
function completetasks($con){
//set all other jobs to complete
$q1 = “SELECT * FROM tasks WHERE time_elapsed = ‘’”;//uncompleted tasks
$r1 = mysqli_query($con,$q1);
while ($current = mysqli_fetch_assoc($r1)) {
$date = date(‘m/d/Y h:i:s a’, time());
$to_time = strtotime($date);
$from_time = strtotime($current[‘start_time’]);
$minutestaken = round(abs($to_time - $from_time) / 60,0);
//tidy t
if ($minutestaken < 10) {
//take minutes as they are
$time_taken =$minutestaken." minutes";
if ($minutestaken < 2) {
$time_taken = $minutestaken." minute";
}if ($minutestaken < 1) {
$time_taken = $minutestaken." minutes";
}
}
if ($minutestaken < 60 && $minutestaken >11) {
//round to nearest 5 minutes
$taken = (round($minutestaken)%5 === 0) ? round($minutestaken) : round(($minutestaken+5/2)/5)*5;
$time_taken = $taken." minutes";
}if($minutestaken>60) {
//give time in hours and minutes
$time_taken = “>”.floor($minutestaken / 60).‘hrs’;
}//hours and minutes
echo $time_taken." work";
}//mysqli fetch assoc
}//completetasks
completetasks($con);
?>
[/CODE]
[/SPOILER]
[SPOILER=“tasks.php //backend”]

[CODE]<?php
//setup
date_default_timezone_set(‘Africa/Nairobi’);
$con = mysqli_connect(“localhost”, “root”,“”, “tracker”) or die (mysqli_error());
//functions
function completetasks($con){
//set all other jobs to complete
$q1 = “SELECT * FROM tasks WHERE time_elapsed = ‘’”;//uncompleted tasks
$r1 = mysqli_query($con,$q1);
while ($current = mysqli_fetch_assoc($r1)) {
$date = date(‘m/d/Y h:i:s a’, time());
$to_time = strtotime($date);
$from_time = strtotime($current[‘start_time’]);
$minutestaken = round(abs($to_time - $from_time) / 60,0);
//tidy time
if ($minutestaken < 10) {
//take minutes as they are
$time_taken =$minutestaken." minutes";
if ($minutestaken < 2) {
$time_taken = $minutestaken." minute";
}if ($minutestaken < 1) {
$time_taken = $minutestaken." minutes";
}
}
if ($minutestaken < 60 && $minutestaken >11) {
//round to nearest 5 minutes
$taken = (round($minutestaken)%5 === 0) ? round($minutestaken) : round(($minutestaken+5/2)/5)*5;
$time_taken = $taken." minutes";
}if($minutestaken>60) {
//give time in hours and minutes
$time_taken = “>”.floor($minutestaken / 60).‘hrs’;
}//hours and minutes
$q6 = “UPDATE tasks SET time_elapsed = ‘$time_taken’ WHERE id = ‘$current[id]’”;
$r6 = mysqli_query($con,$q6);
}//mysqli fetch assoc
}//completetasks
$task = $_POST[‘task’];
completetasks($con);
//add most recent task
$date = date(‘m/d/Y h:i:s a’, time());
$to_time = strtotime($date);
$q = “INSERT INTO tasks (task) VALUES (‘$task’)”;
$r = mysqli_query($con, $q);
//we’re preaparing to retrn data
echo ‘

    ’;

    $q9 = “SELECT task FROM tasks WHERE time_elapsed =‘’”;
    $r9 = mysqli_query($con,$q9);
    while ($item2 = mysqli_fetch_assoc($r9)) {
    ?>

  • <?php echo $item2['task'] ?>
  • <?php } $q7 = "SELECT task, time_elapsed FROM tasks WHERE time_elapsed !='' ORDER BY start_time DESC "; $q7.="LIMIT 5"; $r7 = mysqli_query($con,$q7); while ($item = mysqli_fetch_assoc($r7)) { ?>
  • <?php echo $item['task'] ?><?php echo $item['time_elapsed'] ?>
  • <?php } echo '
'; ?>

[/CODE]
[/SPOILER]
[SPOILER=“tracker.sql //setup db”]

[CODE]-- phpMyAdmin SQL Dump
– version 4.6.5.2
https://www.phpmyadmin.net/

– Host: 127.0.0.1
– Generation Time: Apr 04, 2017 at 02:22 PM
– Server version: 10.1.21-MariaDB
– PHP Version: 7.1.1

SET SQL_MODE = “NO_AUTO_VALUE_ON_ZERO”;
SET time_zone = “+00:00”;

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT /;
/
!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS /;
/
!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION /;
/
!40101 SET NAMES utf8mb4 */;


– Database: tracker



– Table structure for table tasks

CREATE TABLE tasks (
id int(100) NOT NULL,
task varchar(1000) NOT NULL,
time_elapsed varchar(1000) NOT NULL,
start_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
end_time datetime NOT NULL DEFAULT ‘0000-00-00 00:00:00’ ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


– Dumping data for table tasks

INSERT INTO tasks (id, task, time_elapsed, start_time, end_time) VALUES
(103, ‘Code and debug the app’, ‘0 minutes’, ‘2017-03-31 21:00:12’, ‘2017-03-31 21:00:28’),
(104, ‘Find out why text is overlining at the bottom’, ‘0 minutes’, ‘2017-03-31 21:00:28’, ‘2017-03-31 21:00:42’),
(105, ‘Now get to real work using my timer’, ‘3 minutes’, ‘2017-03-31 21:00:42’, ‘2017-03-31 21:03:46’),
(106, ‘And its gone’, ‘3 minutes’, ‘2017-03-31 21:03:46’, ‘2017-03-31 21:07:05’),
(107, ‘Debug the display’, ‘1 minute’, ‘2017-03-31 21:07:05’, ‘2017-03-31 21:07:45’),
(108, ‘Set div to current’, ‘1 minute’, ‘2017-03-31 21:07:45’, ‘2017-03-31 21:08:55’),
(109, ‘Final touches’, ‘0 minutes’, ‘2017-03-31 21:08:55’, ‘2017-03-31 21:09:02’),
(110, ‘Final v2’, ‘1 minute’, ‘2017-03-31 21:09:02’, ‘2017-03-31 21:10:21’),
(111, ‘Start the timer on document load’, ‘1 minute’, ‘2017-03-31 21:10:21’, ‘2017-03-31 21:11:32’),
(112, ‘Applied mathematics’, ‘2 minutes’, ‘2017-03-31 21:11:32’, ‘2017-03-31 21:13:12’),
(113, ‘Testing how many records are shown’, ‘2 minutes’, ‘2017-03-31 21:13:12’, ‘2017-03-31 21:14:58’),
(114, ‘Limit beta test’, ‘3 minutes’, ‘2017-03-31 21:14:58’, ‘2017-03-31 21:17:30’),
(115, ‘’, ‘0 minutes’, ‘2017-03-31 21:17:30’, ‘2017-03-31 21:17:32’),
(116, ‘’, ‘0 minutes’, ‘2017-03-31 21:17:32’, ‘2017-03-31 21:17:42’),
(117, ‘Test for new tas’, ‘0 minutes’, ‘2017-03-31 21:17:42’, ‘2017-03-31 21:17:48’),
(118, ‘Aloow lkjhgfhkjlkhgcfx’, ‘0 minutes’, ‘2017-03-31 21:17:48’, ‘2017-03-31 21:17:49’),
(119, ‘dafsg’, ‘0 minutes’, ‘2017-03-31 21:17:49’, ‘2017-03-31 21:17:50’),
(120, ‘fasgh’, ‘0 minutes’, ‘2017-03-31 21:17:50’, ‘2017-03-31 21:17:51’),
(121, ‘afghd’, ‘0 minutes’, ‘2017-03-31 21:17:51’, ‘2017-03-31 21:17:53’),
(122, ‘adfsgh’, ‘2 minutes’, ‘2017-03-31 21:17:53’, ‘2017-03-31 21:20:09’),
(123, ‘Test the loading dots’, ‘1 minute’, ‘2017-03-31 21:20:09’, ‘2017-03-31 21:20:49’),
(124, ‘Redesign the blinking dots’, ‘5 minutes’, ‘2017-03-31 21:20:49’, ‘2017-03-31 21:25:37’),
(125, ‘Code pen test’, ‘1 minute’, ‘2017-03-31 21:25:37’, ‘2017-03-31 21:26:26’),
(126, ‘’, ‘4 minutes’, ‘2017-03-31 21:26:26’, ‘2017-03-31 21:30:45’),
(127, ‘Check if tasks are coming’, ‘1 minute’, ‘2017-03-31 21:30:45’, ‘2017-03-31 21:31:37’),
(128, ‘Tasks aint showing’, ‘2 minutes’, ‘2017-03-31 21:31:37’, ‘2017-03-31 21:33:30’),
(129, ‘Check if get task is working’, ‘3 minutes’, ‘2017-03-31 21:33:30’, ‘2017-03-31 21:36:45’),
(130, ‘We;re continung where we left from’, ‘>2hrs’, ‘2017-03-31 21:36:45’, ‘2017-03-31 23:58:02’),
(131, ‘Testing the big green dot’, ‘>1hrs’, ‘2017-03-31 23:58:02’, ‘2017-04-01 01:28:58’),
(132, ‘Green dot is working well’, ‘2 minutes’, ‘2017-04-01 01:28:58’, ‘2017-04-01 01:31:01’),
(133, ‘Heartbeat stops after new task’, ‘1 minute’, ‘2017-04-01 01:31:01’, ‘2017-04-01 01:32:03’),
(134, ‘It will no longer blink’, ‘>67hrs’, ‘2017-04-01 01:32:03’, ‘2017-04-03 20:40:41’),
(135, ‘Let off steam for a little while’, ‘2 minutes’, ‘2017-04-03 20:40:42’, ‘2017-04-03 20:42:55’),
(136, ‘OFFLINE FOR A WHILE’, ‘’, ‘2017-04-03 20:42:55’, ‘0000-00-00 00:00:00’);


– Indexes for dumped tables


– Indexes for table tasks

ALTER TABLE tasks
ADD PRIMARY KEY (id);


– AUTO_INCREMENT for dumped tables


– AUTO_INCREMENT for table tasks

ALTER TABLE tasks
MODIFY id int(100) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=137;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT /;
/
!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS /;
/
!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
[/CODE]
[/SPOILER]

hizi ni nini unatafuta reddit brathe

si you just buy a watch?

Cool. I wish I still programmed. Anyway, try to separate the logic of your app from the views etc.

Ok so u wasted your time creating a time manegement application.

As long as he learnt something in the process…

si you just buy a watch?

2 Likes

Cool. I wish I still programmed. Anyway, try to separate the logic of your app from the views etc.

Ok so u wasted your time creating a time manegement application.

1 Like

As long as he learnt something in the process…

2 Likes