I am a new newbie to programming, i am experiencing problems with displaying the added brands listed, first of all it was displaying sadly now it is completely blank. I, have checked the javascript and the create brand.js and the fetch. I have spent hours trying to fix this but still nothing to display, just going to a blank white screen all of a sudden with the last extension of
Creationbrand.php.
<------------------- Add Model -------->
<div class="modal fade" id="addBrandModel" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<form class="form-horizontal" id="submitBrandForm" action="php_action/createBrand.php" method="POST">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title"><i class="fa fa-plus"></i> Add Brand</h4>
</div>
<div class="modal-body">
<div id="add-brand-messages"></div>
<div class="form-group">
<label for="brandName" class="col-sm-3 control-label">Brand Name: </label>
<label class="col-sm-1 control-label">: </label>
<div class="col-sm-8">
<input type="text" class="form-control" id="brandName" placeholder="Brand Name" name="brandName" autocomplete="off">
</div>
</div> <!-- /form-group-->
<div class="form-group">
<label for="brandName" class="col-sm-3 control-label">Brand Cost: </label>
<label class="col-sm-1 control-label">: </label>
<div class="col-sm-8">
<input type="text" class="form-control" id="brandCost" placeholder="Brand Cost" name="brandCost" autocomplete="off">
</div>
</div> <!-- /form-group-->
<div class="form-group">
<label for="brandDescription" class="col-sm-3 control-label">Brand Description: </label>
<label class="col-sm-1 control-label">: </label>
<div class="col-sm-8">
<input type="text" class="form-control" id="brandDescription" placeholder="Brand Description" name="brandDescription" autocomplete="off">
</div>
</div> <!-- /form-group-->
<div class="form-group">
<label for="brandStatus" class="col-sm-3 control-label">Status: </label>
<label class="col-sm-1 control-label">: </label>
<div class="col-sm-8">
<select class="form-control" id="brandStatus" name="brandStatus">
<option value="">~~SELECT~~</option>
<option value="1">Available</option>
<option value="2">Not Available</option>
</select>
</div>
</div> <!-- /form-group-->
</div> <!-- /modal-body -->
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary" id="createBrandBtn" data-loading-text="Loading..." autocomplete="off">Save Changes</button>
</div>
<!-- /modal-footer -->
</form>
<!-- /.form -->
</div>
<!-- /modal-content -->
</div>
<!-- /modal-dailog -->
</div>
<!-- / add modal -->
<-------------------- CreateBrand ----------------------------->
<?php
require_once 'core.php';
$valid['success'] = array('success' => false, 'messages' => array());
if($_POST) {
$saleDate = $_POST['saleDate'];
$saleTime = $_POST['saleTime'];
$beautician_Name = $_POST['beautician_Name'];
$appoint_Service = $_POST['appoint_Service'];
$sale_Notes = $_POST['sale_Notes'];
$client_Contact = $_POST['client_Contact'];
$c_vat = $_POST['c_vat'];
$total_Amount = $_POST['total_Amount'];
$c_discount = $_POST['c_discount'];
$payment_Type = $_POST['payment_Type'];
$sql = "INSERT INTO sale (sale_date, sale_date, beautician_name, appoint_service, sale_notes, client_contact, vat, total_amount, discount, payment_type)
VALUES ('$sale_date', '$sale_date', '$beautician_Name', '$appoint_Service', '$sale_notes', '$client_Contact', '$c_vat' , '$total_Amount' , '$c_discount' , '$payment_Type')";
if($connect->query($sql) === TRUE) {
$valid['success'] = true;
$valid['messages'] = "Successfully Added";
} else {
$valid['success'] = false;
$valid['messages'] = "Error while adding the members";
}
} else {
return false;
} // /else
} // if
} // if in_array
$connect->close();
} // /if $_POST
<------------- Fetch Brand ---------------->
<?php
require_once 'core.php';
$sql = "SELECT brand_id, brand_name, brand_active, brand_status FROM brands WHERE brand_status = 1";
$result = $connect->query($sql);
$output = array('data' => array());
if($result->num_rows > 0) {
// $row = $result->fetch_array();
$activeBrands = "";
while($row = $result->fetch_array()) {
$brandId = $row[0];
// active
if($row[2] == 1) {
// activate member
$activeBrands = "<label class='label label-success'>Available</label>";
} else {
// deactivate member
$activeBrands = "<label class='label label-danger'>Not Available</label>";
}
$button = '<!-- Single button -->
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Action <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a type="button" data-toggle="modal" data-target="#editBrandModel" onclick="editBrands('.$brandId.')"> <i class="glyphicon glyphicon-edit"></i> Edit</a></li>
<li><a type="button" data-toggle="modal" data-target="#removeMemberModal" onclick="removeBrands('.$brandId.')"> <i class="glyphicon glyphicon-trash"></i> Remove</a></li>
</ul>
</div>';
$output['data'][] = array(
$row[1],
$activeBrands,
$button
);
} // /while
} // if num_rows
$connect->close();
echo json_encode($output);
<------------- JS Brand ---------------->
<?php
require_once 'core.php';
//passing into json format - validation
$valid['success'] = array('success' => false, 'messages' => array());
//check if form is submitted
if($_POST) {
$brandName = $_POST['brandName'];
$brandStatus = $_POST['brandStatus'];
$brandCost = $_POST['brandCost'];
$brandDescription = $_POST['brandDescription'];
//insert information into the system
$sql = "INSERT INTO brands (brand_name, brand_status, brand_cost, brand_description, brand_active) VALUES ('$brandName', '$brandStatus', '$brandCost', '$brandDescription', 1)";
if($connect->query($sql) === TRUE) {
$valid['success'] = true;
$valid['messages'] = "Successfully Added";
} else {
$valid['success'] = false;
$valid['messages'] = "Error while adding the members";
}
$connect->close();
} // /if $_POST
Aucun commentaire:
Enregistrer un commentaire