Skip to content

Commit

Permalink
sql updatede
Browse files Browse the repository at this point in the history
  • Loading branch information
DumiduM committed Jun 22, 2018
1 parent 90b8c06 commit 720bc63
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 76 deletions.
2 changes: 1 addition & 1 deletion 2.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@
</div>
<div class="form-group">
<div class="col-sm-12">
<button type="submit" name="submit" class="btn btn-success control-label col-sm-4" onclick="myfunction();" style="font-size: 20px;">Submit</button>
<button type="submit" name="submit" class="btn btn-success control-label col-sm-4" onclick="myfunction();" style="font-size: 20px;">Submit</button>

<script>
function myfunction() {
Expand Down
23 changes: 13 additions & 10 deletions 3.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
<link href="vendor/datatables/dataTables.bootstrap4.css" rel="stylesheet">
<!-- Custom styles for this template-->
<link href="css/sb-admin.css" rel="stylesheet">


</head>

<body class="fixed-nav sticky-footer bg-dark" id="page-top">
Expand Down Expand Up @@ -245,8 +247,17 @@ function getVariety(str){
xmlhttp.open("GET","getVariety.php?q="+str,true);
xmlhttp.send();
}
</script>


</script>
<script>
function myFunction() {
alert(' <?php echo $row["varietyID"] ?>');
<?php $_SESSION['variety_ID']=$row["varietyID"]; ?>
// window.open("4.php");
// this.exit;
}
</script>
<div class="row">
<a href="">
<div class="col-sm-8" id="row-banner" style="background-color:lavenderblush;">
Expand Down Expand Up @@ -280,21 +291,13 @@ function getVariety(str){


<input type="image" src="<?php echo $path ?>" onClick="getVariety('<?php echo $crop ?>')" class = "tile" alt="Avatar" style="width:100%" />

<?php echo "<br><br>"; } ?>

</div>
<div class="col-sm-4" id="variety-col" onclick="" style="background-color:lavender;">

<script>
function myFunction() {
window.open("4.php");
this.exit;
}
</script>



</div>
</div>

Expand Down
96 changes: 54 additions & 42 deletions 4.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php
session_start();
$varietyID=$_GET['varietyID'];
$user=$_SESSION['login_user'];
$date=$_SESSION['date'];
$name=$_SESSION['cropName'];
?>

<!DOCTYPE html>
Expand Down Expand Up @@ -244,8 +248,8 @@
<h5>Projected Scheldue</h5><br>
</div>
<div class="col-md-5">
<h5><strong>Crop : </strong>Potato</h5>
<h5><strong>Starting Date : </strong></h5>
<h5><strong>Crop : </strong> <?php echo $name;?></h5>
<h5><strong>Starting Date : </strong> <?php echo $date;?></h5>
<h5><strong>Land : </strong></h5>
<h5><strong>kit Avalibility : </strong></h5><br>
</div>
Expand All @@ -258,7 +262,7 @@
<tbody>
<?php
include("config.php");
$sql2 = "SELECT * FROM steps WHERE varietyID = '001-001' ORDER BY stepID ASC";
$sql2 = "SELECT * FROM steps WHERE varietyID = '$varietyID' ORDER BY stepID ASC";

$result = $conn->query($sql2);
if ($result->num_rows > 0) {
Expand Down Expand Up @@ -298,12 +302,39 @@
}
</style>

<div class="container">
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">

<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>

</div>
<div class="modal-body">
<img src="<?php echo $result_array[$key]["stepPic"]; ?>" class="media-photo" style="width:100%; ">
<p><strong><?php echo $result_array[$key]["info"] ?></strong></p>
<p><?php echo $result_array[$key]["instruction"] ?></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>

</div>
</div>

</div>



</div>
</div>
</td>
</tr>




<?php }
Expand Down Expand Up @@ -336,35 +367,29 @@ function custom_echo($x, $length)
</section>


<div class="container">
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">

<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>

</div>
<div class="modal-body">
<img src="img\crop_types\potato\001\1.jpg" class="media-photo" style="width:100%; ">
<p><strong>Purchace Seed Potatoes</strong></p>
<p>Potatoes are planted from seed potatoes, potato tubers that have sprouting buds on them. Use only certified seed potatoes as grocery-store potatoes can harbor diseases that may ruin an entire crop. You can order certified seed potatoes from a catalog or buy them at a local garden center. There are numerous potato varieties to choose from.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>

</div>
</div>

</div>



<input type="button" class="btn btn-primary" name="modify" value="Save Changes" onclick="myFunction()">
<form method="POST" action="home.php">
<input type="submit" class="btn btn-primary" value="save" name="save">
</form>

<?php
if(isset($_POST['save'])){

$sql = "INSERT INTO farmercrop (farmerID,verityID,CurrentStepID,dateSc) VALUES ('$user','$varietyID','1','$date')";

if ($conn->query($sql) === TRUE) {
//echo "<script type='text/javascript'>alert('SQL DONE');</script>";
mysqli_close($conn);echo "string";

}
else {
echo "Error: " . $sql . "<br>" . $conn->error;
echo "<script type='text/javascript'>alert('SQL FAIL');</script>";
}
}
?>
<script>
function myFunction() {
window.open("home.php");
Expand All @@ -384,19 +409,6 @@ function myFunction() {
// $variety_Path = $row["varietyPic"];


$sql = "INSERT INTO farmercrop (farmerID,verityID,CurrentStepID,dateSc) VALUES ('123','001-001','1','2018-06-13')";

if ($conn->query($sql) === TRUE) {
echo "<script type='text/javascript'>alert('SQL DONE');</script>";
mysqli_close($conn);

}
else {
echo "Error: " . $sql . "<br>" . $conn->error;
echo "<script type='text/javascript'>alert('SQL FAIL');</script>";
}



?>
<!-- <?php
Expand Down
30 changes: 26 additions & 4 deletions getvariety.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<?php
session_start();
?>
<?php
include "config.php";
$q = $_GET['q'];
Expand All @@ -6,18 +9,25 @@
die('Could not connect: ' . mysqli_error($conn));
}

$sql = "SELECT varietyID,varietyName,harvestRate,varietyPic,price FROM variety WHERE cropID LIKE '$q'";
$sql = "SELECT varietyID,varietyName,harvestRate,varietyPic,price,name FROM variety,crop WHERE variety.cropID LIKE '$q' AND crop.cropID = variety.cropID";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
$row=".";
while($row = $result->fetch_assoc()) {
// echo "<br>". "Name: " . $row["varietyName"]. "<br>" . " harvestRate: ".$row["harvestRate"]."%"."<br>"."Current Price: ". $row["price"]. "<br>";
$variety_Path = $row["varietyPic"];
$varietyID = $row["varietyID"];
$name = $row["name"];
$_SESSION['cropName']="$name";

?>
<div class="row">
<input type="image" src="<?php echo "$variety_Path"; ?>" onClick="alert(' <?php echo $row["varietyID"] ?>');" class = "tile" alt="Avatar" style="width:50%; height:50%; margin-bottom: 10px;" />
<form method = "GET" action ="4.php">

<input type="image" src="<?php echo "$variety_Path"; ?>" onClick="myFunction();" class = "tile" alt="Avatar" style="width:50%; height:50%; margin-bottom: 10px;" />
<input type="hidden" name="varietyID" value="<?php echo "$varietyID"; ?>">
</form>
<?php echo $row["varietyName"] ?><br><br><br><br>
</div>

Expand All @@ -29,5 +39,17 @@
}


$_SESSION['variety_ID']="001";
?>

?>
<script>
// function myFunction() {
// alert(' <?php echo $row["varietyID"] ?>');
// $_SESSION['variety_ID']="$varietyID";
// $_SESSION['cropName']="$name";

// // window.open("4.php");
// // this.exit;
// }


</script>
6 changes: 3 additions & 3 deletions home.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,11 @@

<?php
include("config.php");
$sql = "SELECT distinct c.name FROM crop c,steps s,variety v,farmercrop fc,farmer f WHERE f.name = '$name' AND f.farmerID=fc.farmerID AND v.cropID=c.cropID";
$sql = "SELECT distinct c.name FROM crop c,steps s,variety v,farmercrop fc,farmer f WHERE f.name = '$name' AND f.farmerID=fc.farmerID AND v.cropID=c.cropID AND fc.verityID=v.variety";
$result = $conn->query($sql);
if ($result->num_rows > 0) {

$sql2 = "SELECT DISTINCT s.info, fc.dateSc FROM crop c,steps s,variety v,farmercrop fc,farmer f WHERE fc.farmerID = '123' AND s.stepID = fc.currentStepID AND f.farmerID=fc.farmerID AND v.cropID=c.cropID";
echo "string";
$sql2 = "SELECT DISTINCT s.info, fc.dateSc FROM crop c,steps s,variety v,farmercrop fc,farmer f WHERE fc.farmerID = '$name' AND s.stepID = fc.currentStepID AND f.farmerID=fc.farmerID AND v.cropID=c.cropID";
$result2 = $conn->query($sql2);
if ($result2->num_rows > 0) {
while($row = $result2->fetch_assoc()) {
Expand Down
16 changes: 0 additions & 16 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,4 @@ $(document).ready(function () {

});

function getVariety(str){
alert("Check");
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (this.readyState==4 && this.status==200) {
document.getElementById("variety-col").innerHTML=this.responseText;
}
}
xmlhttp.open("GET","getVariety.php?q="+str,true);
xmlhttp.send();

}

0 comments on commit 720bc63

Please sign in to comment.