project-data-fix #35

Merged
rodude123 merged 2 commits from project-data-fix into master 2023-06-26 18:13:40 +01:00
6 changed files with 16 additions and 14 deletions

View File

@ -64,7 +64,7 @@ class projectData
if ($isMainProject === "true") if ($isMainProject === "true")
{ {
$stmtMainProject = $conn->prepare("UPDATE projects SET isMainProject = 0;"); $stmtMainProject = $conn->prepare("UPDATE projects SET isMainProject = 0 WHERE isMainProject = 1;");
$stmtMainProject->execute(); $stmtMainProject->execute();
} }
@ -129,7 +129,7 @@ class projectData
$conn = dbConn(); $conn = dbConn();
if ($isMainProject === "true") if ($isMainProject === "true")
{ {
$stmtMainProject = $conn->prepare("UPDATE projects SET isMainProject = 0;"); $stmtMainProject = $conn->prepare("UPDATE projects SET isMainProject = 0 WHERE isMainProject = 1;");
$stmtMainProject->execute(); $stmtMainProject->execute();
} }
@ -173,7 +173,7 @@ class projectData
// update the database with the new image location // update the database with the new image location
$conn = dbConn(); $conn = dbConn();
$stmt = $conn->prepare("UPDATE projects SET imgLocation = :imgLocation WHERE ID = :ID"); $stmt = $conn->prepare("UPDATE projects SET imgLocation = :imgLocation WHERE ID = :ID");
$stmt->bindParam(":imgLocation", $targetFile); $stmt->bindParam(":imgLocation", $targetFile["imgLocation"]);
$stmt->bindParam(":ID", $ID); $stmt->bindParam(":ID", $ID);
$stmt->execute(); $stmt->execute();

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -64,7 +64,7 @@ class projectData
if ($isMainProject === "true") if ($isMainProject === "true")
{ {
$stmtMainProject = $conn->prepare("UPDATE projects SET isMainProject = 0;"); $stmtMainProject = $conn->prepare("UPDATE projects SET isMainProject = 0 WHERE isMainProject = 1;");
$stmtMainProject->execute(); $stmtMainProject->execute();
} }
@ -129,7 +129,7 @@ class projectData
$conn = dbConn(); $conn = dbConn();
if ($isMainProject === "true") if ($isMainProject === "true")
{ {
$stmtMainProject = $conn->prepare("UPDATE projects SET isMainProject = 0;"); $stmtMainProject = $conn->prepare("UPDATE projects SET isMainProject = 0 WHERE isMainProject = 1;");
$stmtMainProject->execute(); $stmtMainProject->execute();
} }
@ -173,7 +173,7 @@ class projectData
// update the database with the new image location // update the database with the new image location
$conn = dbConn(); $conn = dbConn();
$stmt = $conn->prepare("UPDATE projects SET imgLocation = :imgLocation WHERE ID = :ID"); $stmt = $conn->prepare("UPDATE projects SET imgLocation = :imgLocation WHERE ID = :ID");
$stmt->bindParam(":imgLocation", $targetFile); $stmt->bindParam(":imgLocation", $targetFile["imgLocation"]);
$stmt->bindParam(":ID", $ID); $stmt->bindParam(":ID", $ID);
$stmt->execute(); $stmt->execute();

View File

@ -18,9 +18,10 @@
class="fa fa-caret-right"></i></a></li> class="fa fa-caret-right"></i></a></li>
<li class="dropdown"> <li class="dropdown">
<ul> <ul>
<li><a href="#" id="goToAddPost" class="active"><span>&lt;</span>Add Blog Post<span>&gt;</span></a> <li><a href="#" id="goToAddPost"><span>&lt;</span>Add Blog Post<span>&gt;</span></a>
</li> </li>
<li><a href="#" id="goToEditPost"><span>&lt;</span>Edit Blog Post<span>&gt;</span></a></li> <li><a href="#" id="goToEditPost" class="active"><span>&lt;</span>Edit Blog
Post<span>&gt;</span></a></li>
</ul> </ul>
</li> </li>
<li><a href="#" id="logout"><span>&lt;</span>Logout<span>&gt;</span></a></li> <li><a href="#" id="logout"><span>&lt;</span>Logout<span>&gt;</span></a></li>
@ -205,6 +206,8 @@
<input type="submit" value="Add new blog post" class="btn btnPrimary boxShadowIn boxShadowOut"> <input type="submit" value="Add new blog post" class="btn btnPrimary boxShadowIn boxShadowOut">
</form> </form>
</section> </section>
</main> </main>
<script src="js/editor.js"></script> <script src="js/editor.js"></script>

View File

@ -56,7 +56,7 @@ document.addEventListener('DOMContentLoaded', () =>
{ {
json.forEach(item => json.forEach(item =>
{ {
addProject(item["ID"], (item["isMainProject"] === "1" ? "true" : "false"), (item["imgLocation"] === "") ? "../imgs/placeholder.png" : item["imgLocation"], item["title"], item["information"], item["projectLink"], item["gitLink"]); addProject(item["ID"], (item["isMainProject"] === 1 ? "true" : "false"), (item["imgLocation"] === "") ? "../imgs/placeholder.png" : item["imgLocation"], item["title"], item["information"], item["projectLink"], item["gitLink"]);
}) })
return; return;
} }
@ -353,7 +353,6 @@ document.querySelector("#projError .close").addEventListener("click", () =>
document.querySelector("#addPostError .close").addEventListener("click", () => document.querySelector("#addPostError .close").addEventListener("click", () =>
document.querySelector("#addPostError").classList.toggle("hidden")); document.querySelector("#addPostError").classList.toggle("hidden"));
document.querySelector("#addPostSuccess .close").addEventListener("click", () => document.querySelector("#addPostSuccess .close").addEventListener("click", () =>
document.querySelector("#addPostSuccess").classList.toggle("hidden")); document.querySelector("#addPostSuccess").classList.toggle("hidden"));
@ -777,7 +776,7 @@ function updateProjectItem(id, e)
{ {
window.location.href = "./"; window.location.href = "./";
return; return;
}ujh }
document.querySelector(`#projError${id}`).classList.remove("hidden"); document.querySelector(`#projError${id}`).classList.remove("hidden");
document.querySelector(`#projError${id} div`).innerHTML = updatedProjectImage.error; document.querySelector(`#projError${id} div`).innerHTML = updatedProjectImage.error;
@ -856,7 +855,7 @@ function addProject(id , isMainProject, imgLocation, title, information, project
</div> </div>
<div class="formControl isMainProject"> <div class="formControl isMainProject">
<label class="checkContainer" for="isMainProject${id}">Is It The Main Project <label class="checkContainer" for="isMainProject${id}">Is It The Main Project
<input type="checkbox" id="isMainProject${id}" name="isMainProject${id}" ${(isMainProject === "true" ? "checked" : "")}> <input type="checkbox" id="isMainProject${id}" name="isMainProject${id}" ${(isMainProject === "true" ? "checked=''" : "")}>
<span class="checkmark"></span> <span class="checkmark"></span>
</label> </label>
</div> </div>