/////////////////////////////////////////////////////////////// //bootstrap css & js/////////////////////////////////// ///////////////////////////////////////////////////////////////
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js">/////////////////////////////////////////////////////////////// //jquery////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script> <script src="js/bootstrap.min.js"></script> <title>title</title> <script src="script.js"></script>/* PHP */
session_start(); //must be at top of page before headers are sent. remember to sanitize inputs. $_SESSION["favcolor"] = "green";
//connects to the database
global $connection; in every function
//CREATE
$age = mysqli_real_escape_string($connection, $_POST['title']); //SANITIZE INPUTS!
$query = "INSERT INTO posts(title,link,category,submitter,postDate,image) WHERE id=$id "; //Crucial ending space $query .= "VALUES ('$title','$link','$category','$submitter','$postDate','$image')";
$result = mysqli_query($connection, $query);
if (!$result){
die("Query failed to post..." . mysqli_error($result));
}else{echo "Post created.";}
}
//READ///
function displayPosts($limit){ if($limit == 0){ echo $limit; } global $connection; //VITAL $query = "SELECT * from posts order by id desc limit $limit"; $result = mysqli_query($connection, $query);
if (!$result){
die("Query failed");
}
//for every row in mysql
while ($row = mysqli_fetch_assoc($result)){
//pull all the data
$id = $row['id'];
$title = $row['title'];
//get how many comments for that id
$commentCountQuery = "SELECT COUNT(*) as total FROM comments where id=$id ";
$result2 = mysqli_query($connection, $commentCountQuery);
if (!$result2){
die("Comment Count Query failed");
}
$temp = mysqli_fetch_assoc($result2);
$commentCount = $temp['total'];
stylePosts($category, $postDate, $link, $title, $id, $submitter, $commentCount, $image);
}
}
////UPDATE////
Unable to update."); }else{ echo "Updated."; } } // DELETE // function deletePosts(){ global $connection; //VITAL $id = $_POST['id']; $query = "DELETE FROM posts WHERE id=$id"; $result = mysqli_query($connection, $query); if (!$result) { //////////FAIL//////// die("Unable to delete record." . mysqli_error($connection)); }else{ ////////SUCCESS/////// echo "deleted."; } } /* JQUERY */ $("p").css("background-color", "yellow"); //////////////////////////// EVENTS //////////////////////////// $("p").click(function(){ $(this).hide(); //.show }); .mouseenter(){} .mouseleave(){} $(document).ready(function(){ // jQuery methods go here... }); ///////AJAX////////// $(document).ready(function(){ $("button").click(function(){ $("#div1").load("demo_test.txt"); }); }); </script> Get External Content /* BOOTSTRAP */ https://v4-alpha.getbootstrap.com/components/forms/ https://www.w3schools.com/bootstrap/bootstrap_forms_inputs.asp Add class .form-control to all textual , <textarea>, and elements Input types: text, password, datetime, datetime-local, date, month, time, week, number, email, url, search, tel, and color. Email address We'll never share your email with anyone else.
data: { tracking_number: trackingNumber }, //key value pairs in JSON format
crossDomain: true, //possibly not necessary
success: function (msg) {
alert("Tracking Number Saved");
}
});
});
inside the controller or api, we retrieve the variables from POST and GET
public function updatetracking(){
$tracking_number = $_POST['tracking_number'];
//TODO sanitize inputs... this is an admin only page, so not a huge concern
$order_id = $_GET['order_id'];
$this->load->model('checkout/order');
$this->model_checkout_order->setTracking($_POST['tracking_number'], $_GET['order_id']); //calling a function within model checkout order and passing a post and a get
}
and we are calling this function in the model, and we're done.
public function setTracking($data,$order_id){
$this->db->query("UPDATE " . DB_PREFIX . "order SET shipping_tracking = '" . $data . "' WHERE order_id = '" . (int)$order_id . "'");
}