Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed adding tree, but editing doesn't select correct grower.

  • Loading branch information...
commit d1d0b8158cc2ae54be72e0840663c844d67c64df 1 parent efbb1ab
Steven authored

Showing 1 changed file with 10 additions and 4 deletions. Show diff stats Hide diff stats

  1. +10 4 ajax.php
14 ajax.php
@@ -227,7 +227,7 @@ function updateTree($exist){
227 227 global $db;
228 228 global $data;
229 229 $id = $_REQUEST['id'];
230   - $grower_id = $_REQUEST['grower_id'];
  230 + $grower_id = $_REQUEST['tree-grower-name'];
231 231 $tree_type_id = $_REQUEST['tree_type_id'];
232 232 $varietal = $_REQUEST['varietal'];
233 233 $number = $_REQUEST['number'];
@@ -235,8 +235,10 @@ function updateTree($exist){
235 235 $chemicaled_id = $_REQUEST['chemicaled_id'];
236 236
237 237 if($exist){
238   - $sql = "Update grower_trees Set grower_id='".$grower_id."', tree_type='".$tree_type_id."', varietal='".$varietal."', number='".$number."', avgHeight_id='".$avgHeight_id."', chemicaled='".$chemicaled_id."' where id=".$id;
  238 + $sql = "Update grower_trees Set grower_id='$grower_id', tree_type='$tree_type_id', varietal='$varietal', number='$number', avgHeight_id='$avgHeight_id', chemicaled='$chemicaled_id' where id=$id";
239 239 $r = $db->q($sql);
  240 + if (getError($r))
  241 + return;
240 242 for ($i=1; $i<13 ; $i++) {
241 243 if (isset($_GET["tree_month$i"])) { //it is checked
242 244 $sql = "Insert into month_harvests(tree_id, month_id) Values($id,$i)";
@@ -246,12 +248,14 @@ function updateTree($exist){
246 248 $r = $db->q($sql);
247 249 }
248 250 }
249   -
  251 + getError($r);
250 252 }
251 253 else{
252 254 $sql = "INSERT INTO grower_trees(grower_id, tree_type, varietal, number, avgHeight_id, chemicaled)
253 255 VALUES ('$grower_id', '$tree_type_id', '$varietal', '$number', '$avgHeight_id', '$chemicaled_id')";
254 256 $r = $db->q($sql);
  257 + if (getError($r))
  258 + return;
255 259 $treeID = mysql_insert_id();
256 260 for ($i=1; $i<13 ; $i++) {
257 261 if (isset($_GET["tree_month$i"])) { //it is checked
@@ -1252,7 +1256,9 @@ function dateToStr($dateStr) {
1252 1256 }
1253 1257 $data['id'] = 10;
1254 1258 $data['title'] = 'Grower-Name';
1255   - $sql = "SELECT id, Concat(first_name,' ',middle_name,' ',last_name), phone, street, city FROM growers ;";
  1259 + $sql = "SELECT id, Concat(first_name,' ',middle_name,' ',last_name), phone, street, city
  1260 + FROM growers
  1261 + ORDER BY first_name ASC";
1256 1262 getName($sql);
1257 1263 break;
1258 1264

0 comments on commit d1d0b81

Steven

This was the culprit.

Please sign in to comment.
Something went wrong with that request. Please try again.