KOTS202 0 Newbie Poster

Hi all,

I am new to web development. So please be easy on me and try and explain somethings in detail.

I am building a edit page for something else I am building. It is all PHP driven with a MySQL database. Well anyway my boss want a inline on this one single page. So I am started using this tutorial at this website I am using the exact same code that is given to me with just a few minor changes. The problem is that it works but it only works for inputting two fields. This is my PHP

<?php
include('setup.php');
$type = $_GET['type'];
$id = $_GET['recordId'];
$value = $_POST['data'];

if($type == "start"  || $type="stop"){
    echo "now $value";
    $value = date('H:i:s', strtotime("now $value"));
} else {
    $query = "UPDATE timesheets SET ".$type." = \"".$value."\" WHERE id = ".$id;
    mysql_query($query);
    echo $query;
}

?>

and this is page I am trying to edit on

<?php
include("html.php");
siteheader();
?>

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>

<script type="text/javascript">
$(function(){
/$.inlineEdit({
start: 'timesheetUpdater.php?type=start&amp;recordId=',
out: 'timesheetUpdater.php?type=stop&amp;recordId=',
task: 'timesheetUpdater.php?type=taskid&amp;recordId=',
description: 'timesheetUpdater.php?type=description&amp;recordId='
}, {
animate: false,
afterSave: function(data){
}
});
/
$('.editText').editable
});
</script>
<style type="text/css">
#data td {
width: 120px;
vertical-align: top;
cursor: pointer;
}
.editFieldSaveControllers {
width: 250px;
font-size: 80%;
}
.editableSingle button, .editableSingle input {
padding: 0px;
}
a.editFieldRemove {
color: red;
}
</style>
</head>

<body>

Day In Out Time Worked Task Number Customer Service Description <?php $searchDate = date('Y-m-d', strtotime('now')); if(isset($_GET['date'])){ $searchDate = $_GET['date']; } $query = "SELECT `timesheets`.*, DATE_FORMAT(date, '%Y-%m-%d') as checkDate FROM `timesheets` WHERE user = ".$user[id]." AND date = '$searchDate'"; $result = mysql_query($query); $num = mysql_num_rows($result);

$i = 0; $totalHours = 0; while ($i < $num) { $id = mysql_result($result, $i, "id"); $f1 = mysql_result($result, $i, "checkDate"); $f2 = date("g:i A", strtotime(mysql_result($result, $i, "start"))); $f3 = date("g:i A", strtotime(mysql_result($result, $i, "stop"))); $f4 = (strtotime($f3) - strtotime($f2)) / (3600); $f5 = mysql_result($result, $i, "taskid"); $f6 = mysql_result($result, $i, "customer"); $f7 = mysql_result($result, $i, "service"); $f8 = mysql_result($result, $i, "description");

$totalHours += $f4; $f4 .= " Hrs"; ?> <?php echo "$f1"; ?> <?php echo "$f2"; ?> <?php echo "$f3"; ?> <?php echo "$f4"; ?> <?php echo "$f5"; ?> <?php echo "$f6"; ?> <?php echo "$f7"; ?> <?php echo "$f8"; ?> <?php $i++; } //$i < $num ?> </body>
</html>
<?php sitefooter(); ?>

The javascript file I got from the website is exactly the same. Can someone help me and explain what I am doing wrong?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.