search feature in jquery Select2 function is not working? - javascript

the code is running as intended but the select2 function is not working. Don't get any error or anything just the search option is not there
<?php
require 'dbConfig.php';
?>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>[enter image description here][1]
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png">
<link rel="icon" type="image/png" href="JtLogo.ico" sizes="32x32">
<link rel="icon" type="image/png" href="JtLogo.ico" sizes="16x16">
<link rel="manifest" href="manifest.json">
<link rel="mask-icon" href="safari-pinned-tab.svg" color="#d9230f">
<meta name="theme-color" content="#ffffff">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,400italic,500,700">
<link rel="stylesheet" href="css/vendor.min.css">
<link rel="stylesheet" href="css/elephant.min.css">
<link rel="stylesheet" href="css/application.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/jquery.blockUI.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/css/select2.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/js/select2.full.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<style type="text/css">
</style>
</head>
<body style="padding: 0%;">
<div style="position: fixed; width: 100%; background-color: white; padding: 4px;"><div class="row gutter-xs" style="background-color: #029ACF;">
<div style="text-align: center; line-height: 30px;"><font style="color: #FFF;">SAMPLE TRACK (KOLKATA)</font></div>
</div>
<div class="row gutter-xs" style="margin-top: 5px;">
<button type="button" class="btn btn-info btn-xs" style="margin-left: 5px;" onclick="window.location='home.php';">HOME</button>
<button type="button" class="btn btn-default btn-xs" style="margin-right: 5px; float: right;" id="logout" onclick="window.location='logout.php';"><span class="icon icon-sign-out" style="line-height: 18px;"></span></button>
<button type="button" class="btn btn-default btn-xs" style="margin-right: 0px; float: right;" disabled="">
LOGOUT
</button>
</div>
<br>
<div class="row gutter-xs">
<div class="col-xs-6 col-md-2">
<select class="custom-select custom-select-sm" name="cbosale" id="cbosale" required>
<option value="">Select Sale</option>
<?php
echo $sql1 = "SELECT Query";
$res1 = mysqli_query($db,$sql1);
$i1 = 0;
while($r1 = mysqli_fetch_array($res1))
{
?>
<option value="<?php echo $r1[0]; ?>"><?php echo $r1[0]; ?>/<?php echo $r1[1]; ?></option>
<?php $i1++; } ?>
</select>
</div>
<div class="col-xs-6 col-md-2">
<select class="custom-select custom-select-sm" name="cbogarden" id="cbogarden">
<option value="">Select Garden</option>
<?php
echo $sql1 = "SELECT Query";
$res1 = mysqli_query($db,$sql1);
$i1 = 0;
while($r1 = mysqli_fetch_array($res1))
{
?>
<option value="<?php echo $r1[0]; ?>"><?php echo $r1[0]; ?></option>
<?php $i1++; } ?>
</select>
</div>
</div>
<br>
<div class="row gutter-xs">
<div class="col-xs-6 col-md-2">
<select class="custom-select custom-select-sm" name="cbocat" id="cbocat" required>
<option value="">Select Category</option>
<?php
$sql = "SELECT Query";
$res = mysqli_query($db,$sql);
$i = 0;
while($r = mysqli_fetch_array($res))
{
?>
<option value="<?php echo $r[0]; ?>"><?php echo $r[0]; ?></option>
<?php $i++; } ?>
</select>
</div>
<div class="col-xs-6 col-md-2">
<div id="showgrade">
<select class="custom-select custom-select-sm" name="cbograde" id="cbograde">
<option value="">Select Grade</option>
<?php
$sql = "SELECT Query"; //GradeCode CategoryCode GardenCode
$res = mysqli_query($db,$sql);
$i = 0;
while($r = mysqli_fetch_array($res))
{
?>
<option value="<?php echo $r[0]; ?>"><?php echo $r[0]; ?></option>
<?php $i++; } ?>
</select>
</div>
</div>
</div>
<br/>
<div class="row gutter-xs">
<div class="col-xs-12 col-md-4">
<button type="button" class="btn btn-primary" id="filter">SHOW</button>
</div>
</div>
<br/>
<div class="row gutter-xs">
<div class="col-xs-12 col-md-4">
<a class="btn btn-primary float-right" href="cmail.php">E-Mail Selected DATA</a>
<a class="btn btn-primary float-right" href="catalogue_save_exl.php">Download SELECTION</a>
</div>
</div>
</div>
<br/><br/><br/><br/><br/><br/>
<div class="row gutter-xs" style="margin-top: 155px; padding: 4px;">
<div id="showdata">
<div id="postList">
</div>
<script type="text/javascript">
$(document).ready(function(){
$('#filter').click(function(){
var sale = $('#cbosale').val();
var cat = $('#cbocat').val();
var grade = $('#cbograde').val();
var garden = $('#cbogarden').val();
$.ajax({
type: 'POST',
url: 'catalogue_data.php',
data: 'sale='+sale+'&cat='+cat+'&grade='+grade+'&garden='+garden,
success: function(html){
$('#postList').html(html);
}
});
});
});
$(document).ready(function(){
$('#cbocat').change(function(){
var ttype = $('#cbocat').val();
$.ajax({
type: 'POST',
url: 'get_grade.php',
data: 'ttype='+ttype,
success: function(html){
$('#showgrade').html(html);
}
});
});
});
$(document).ready(function () {
$("select").select2();
});
</script>
</div>
</div>
</body>
</html>
please check the below link to see the output.
The main functionality if the website is working and has no issues, it's just the select2 function this is not working

Try out this code:
<?php
require 'dbConfig.php';
?>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content=" width=device-width,initial-scale=1,user-scalable=no">
<meta name="theme-color" content="#ffffff">
<title></title>[enter image description here][1]
<!-- Icons -->
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png">
<link rel="icon" type="image/png" href="JtLogo.ico" sizes="32x32">
<link rel="icon" type="image/png" href="JtLogo.ico" sizes="16x16">
<link rel="mask-icon" href="safari-pinned-tab.svg" color="#d9230f">
<!-- Manifest -->
<!-- <link rel="manifest" href="manifest.json"> -->
<!-- CSS -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,400italic,500,700">
<link rel="stylesheet" href="css/vendor.min.css">
<link rel="stylesheet" href="css/elephant.min.css">
<link rel="stylesheet" href="css/application.min.css">
<!-- BootStrap & Select2 CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/css/select2.min.css" />
<!-- JQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<!-- jQuery Mobile -->
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.js"></script>
<!-- Bootstrap & Select2 JS -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/js/select2.full.min.js"></script>
<!-- Script -->
<script type="text/javascript" src="js/jquery.blockUI.js"></script>
</head>
<body style="padding: 0%;">
<div style="position: fixed; width: 100%; background-color: white; padding: 4px;">
<div class="row gutter-xs" style="background-color: #029ACF;">
<div style="text-align: center; line-height: 30px;">
<font style="color: #FFF;">SAMPLE TRACK (KOLKATA)</font>
</div>
</div>
<div class="row gutter-xs" style="margin-top: 5px;">
<button type="button" class="btn btn-info btn-xs" style="margin-left: 5px;" onclick="window.location='home.php';">
HOME
</button>
<button type="button" class="btn btn-default btn-xs" style="margin-right: 5px; float: right;" id="logout" onclick="window.location='logout.php';">
<span class="icon icon-sign-out" style="line-height: 18px;"></span>
</button>
<button type="button" class="btn btn-default btn-xs" style="margin-right: 0px; float: right;" disabled="">
LOGOUT
</button>
</div>
<br>
<div class="row gutter-xs">
<div class="col-xs-6 col-md-2">
<select class="custom-select custom-select-sm" name="cbosale" id="cbosale" required>
<option value="">Select Sale</option>
<?php
echo $sql1 = "SELECT Query";
$res1 = mysqli_query($db,$sql1);
$i1 = 0;
while($r1 = mysqli_fetch_array($res1)){
?>
<option value="<?php echo $r1[0]; ?>"><?php echo $r1[0]; ?>/<?php echo $r1[1]; ?></option>
<?php $i1++; } ?>
</select>
</div>
<div class="col-xs-6 col-md-2">
<select class="custom-select custom-select-sm" name="cbogarden" id="cbogarden">
<option value="">Select Garden</option>
<?php
echo $sql1 = "SELECT Query";
$res1 = mysqli_query($db,$sql1);
$i1 = 0;
while($r1 = mysqli_fetch_array($res1))
{
?>
<option value="<?php echo $r1[0]; ?>"><?php echo $r1[0]; ?></option>
<?php $i1++; } ?>
</select>
</div>
</div>
<br>
<div class="row gutter-xs">
<div class="col-xs-6 col-md-2">
<select class="custom-select custom-select-sm" name="cbocat" id="cbocat" required>
<option value="">Select Category</option>
<?php
$sql = "SELECT Query";
$res = mysqli_query($db,$sql);
$i = 0;
while($r = mysqli_fetch_array($res))
{
?>
<option value="<?php echo $r[0]; ?>"><?php echo $r[0]; ?></option>
<?php $i++; } ?>
</select>
</div>
<div class="col-xs-6 col-md-2">
<div id="showgrade">
<select class="custom-select custom-select-sm" name="cbograde" id="cbograde">
<option value="">Select Grade</option>
<?php
$sql = "SELECT Query"; //GradeCode CategoryCode GardenCode
$res = mysqli_query($db,$sql);
$i = 0;
while($r = mysqli_fetch_array($res))
{
?>
<option value="<?php echo $r[0]; ?>"><?php echo $r[0]; ?></option>
<?php $i++; } ?>
</select>
</div>
</div>
</div>
<br/>
<div class="row gutter-xs">
<div class="col-xs-12 col-md-4">
<button type="button" class="btn btn-primary" id="filter">SHOW</button>
</div>
</div>
<br/>
<div class="row gutter-xs">
<div class="col-xs-12 col-md-4">
<a class="btn btn-primary float-right" href="cmail.php">E-Mail Selected DATA</a>
<a class="btn btn-primary float-right" href="catalogue_save_exl.php">Download SELECTION</a>
</div>
</div>
</div>
<br/><br/><br/><br/><br/><br/>
<div class="row gutter-xs" style="margin-top: 155px; padding: 4px;">
<div id="showdata">
<div id="postList">
</div>
<script type="text/javascript">
$(document).ready(function(){
$('#filter').click(function(){
var sale = $('#cbosale').val();
var cat = $('#cbocat').val();
var grade = $('#cbograde').val();
var garden = $('#cbogarden').val();
$.ajax({
type: 'POST',
url: 'catalogue_data.php',
data: 'sale='+sale+'&cat='+cat+'&grade='+grade+'&garden='+garden,
success: function(html){
$('#postList').html(html);
}
});
});
});
$(document).ready(function(){
$('#cbocat').change(function(){
var ttype = $('#cbocat').val();
$.ajax({
type: 'POST',
url: 'get_grade.php',
data: 'ttype='+ttype,
success: function(html){
$('#showgrade').html(html);
}
});
});
});
$(document).ready(function () {
$("select").select2();
});
</script>
</div>
</div>
</body>
</html>

Related

How to add to zip csv file with generated files list

I have question about download file with php script and add it to zip.
I using now this script
<?php include "zahlavi.php"; ?>
<?php include_once('assets/bs4-paginator.class.php'); ?>
<?php include ('assets/config.php'); ?>
<!doctype html>
<html lang="en-US" xmlns:fb="https://www.facebook.com/2008/fbml"
xmlns:addthis="https://www.addthis.com/help/api-spec" prefix="og: http://ogp.me/ns#" class="no-js">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Generator</title>
<link rel="shortcut icon" href="https://demo.learncodeweb.com/favicon.ico">
<link rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-
GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css"
integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/"
crossorigin="anonymous">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- Global site tag (gtag.js) - Google Analytics -->
</head>
<body>
</div>
<div class="container">
<div class="panel panel-default">
<div class="panel-heading clearfix"><i class="fa fa-fw fa-globe"></i>
<strong>Prohlížení</strong>
<div class="panel-body">
<div class="col-sm-12">
<h5><i class="fa fa-fw fa-search"></i>Hledat PM</h5>
<form method="get">
<div class="row">
<div class="col-sm-2">
<div class="form-group">
<label>Stav</label>
<input type="text" name="zak_stav" id="zak_stav" class="form-control"
value="<?php echo isset($_REQUEST['zak_stav'])?$_REQUEST['zak_stav']:''?>" placeholder="Zadat
stav...">
</div>
</div>
<div class="col-sm-2">
<div class="form-group">
<label>Datum ukončení el</label>
<input type="text" name="zak_termin_ukonceni_elektrina" id="zak_termin_ukonceni_elektrina" class="form-control" value="<?php echo isset($_REQUEST['zak_termin_ukonceni_elektrina'])?$_REQUEST['zak_termin_ukonceni_elektrina']:''?>" placeholder="Zadat termin ukončení..">
</div>
</div>
<div class="col-sm-2">
<div class="form-group">
<label>Datum ukončení pl</label>
<input type="text" class="tel form-control" name="zak_termin_ukonceni_plyn" id="zak_termin_ukonceni_plyn" x-autocompletetype="tel" placeholder="Zadat termín ukončení.." value="<?php echo isset($_REQUEST['zak_termin_ukonceni_plyn'])?$_REQUEST['zak_termin_ukonceni_plyn']:''?>">
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<label> </label>
<div>
<button type="submit" name="submit" value="search" id="submit" class="btn btn-primary"><i class="fa fa-fw fa-search"></i> Hledat</button>
<i class="fa fa-fw fa-sync"></i> Vyčistit filtr
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<hr>
<div class="table table-responsive">
<form method="post" action="createzip.php">
<table class="table table-striped table-bordered table-hover">
<thead>
<tr class="bg-primary text-white">
<th width="25">id#</th>
<th>nazev pm</th>
<th>Jmeno</th>
<th>Prijmeni</th>
<th>Mesto</th>
<th>Ulice</th>
<th>Datum narozeni</th>
</tr>
</thead>
<tbody>
<?php
$condition = '';
if(isset($_REQUEST['zak_stav']) and $_REQUEST['zak_stav']!=""){
$condition .= ' AND zak_stav LIKE "%'.$_REQUEST['zak_stav'].'%" ';
}
if(isset($_REQUEST['zak_termin_ukonceni_elektrina']) and $_REQUEST['zak_termin_ukonceni_elektrina']!=""){
$condition .= ' AND zak_termin_ukonceni_elektrina LIKE "%'.$_REQUEST['zak_termin_ukonceni_elektrina'].'%" ';
}
if(isset($_REQUEST['zak_termin_ukonceni_plyn']) and $_REQUEST['zak_termin_ukonceni_plyn']!=""){
$condition .= ' AND zak_termin_ukonceni_plyn LIKE "%'.$_REQUEST['zak_termin_ukonceni_plyn'].'%" ';
}
$db = new mysqli('','','','');
mysqli_set_charset($db,"utf8");
$pages->default_ipp = 15;
$fileQry = $db->query("SELECT * FROM zakaznici WHERE 1 ".$condition." ORDER BY id_tabulky DESC LIMIT 30");
$pages->items_total = count($fileQryql);
$pages->mid_range = 9;
$pages->paginate();
if($fileQry->num_rows>0){
$s = '';
while($row = $fileQry->fetch_assoc()){
$s++;
?>
<tr>
<td><?php echo $s;?></td>
<td>
<div class="custom-control custom-checkbox mb-3">
<input type="checkbox" name="fileId[]" class="custom-control-input" id="checkbox<?php echo $row['id_tabulky']?>" value="<?php echo $row['id_tabulky']?>">
<label type="hiden" class="custom-control-label" for="checkbox<?php echo $row['id_tabulky']?>"><?php echo $row['zak_soubor_pm'];?></label>
</div>
</td>
<td>
<?php echo $row['zak_jmeno'];?>
</td>
<td>
<?php echo $row['zak_prijmeni'];?>
</td>
<td>
<?php echo $row['zak_mesto'];?>
</td>
<td>
<?php echo $row['zak_ulice'];?>
</td>
<td>
<?php echo $row['zak_datum_narozeni'];?>
</td>
</tr>
<?php
}
} ?>
<tr>
<td colspan="2"><button type="submit" name="createzip" id="createzip" value="createzip" class="btn btn-primary"><i class="fa fa-archive"></i> Stáhnout vybrané PM</button></td>
</tr>
</tbody>
</table>
</form>
</div>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
<script>
$(document).ready(function(){
$('input[type="file"]').on('change', function () {
let filenames = [];
let files = document.getElementById('customFile').files;
if(files.length>1){
filenames.push('Total Files ('+files.length+')');
}else{
for (let i in files) {
if (files.hasOwnProperty(i)) {
filenames.push(files[i].name);
}
}
}
$(this).next('.custom-file-label').html(filenames.join(','));
});
});
</script>
</body>
</html>
<?php include "zapati.php"; ?>
For download files from database. Script works well
but I need add to this zip csv or excel file with file names with full path in rows with id of exported rows and more info from DB etc name of customer...
How I can do this ? How to add CSV export from this mysql table to this generated zip with files ?
Createzip.php contain is here:
<?php
if(isset($_REQUEST['createzip']) and $_REQUEST['createzip']!=""){
extract($_REQUEST);
$filename = 'temp/vygenerovane-pm.zip';
$db = new mysqli('','-
','','');
mysqli_set_charset($db,"utf8");
$fileQry = $db->query('SELECT * FROM zakaznici WHERE id_tabulky IN
('.implode(",",$fileId).')');
$zip = new ZipArchive;
if ($zip->open($filename, ZipArchive::CREATE)){
while($row = $fileQry->fetch_assoc()){
$zip->addFile(getcwd().'/'.'/'.$row['zak_soubor_pm'],
$row['zak_soubor_pm']);
}
$zip->close();
header("Content-type: application/zip");
header("Content-Disposition: attachment; filename=$filename");
header("Content-length: " . filesize($filename));
header("Pragma: no-cache");
header("Expires: 0");
readfile("$filename");
unlink($filename);
}else{
echo 'Failed!';
}
}
?>
Solved. Before download zip I create csv file and save it to temp after that link in to ZIP and after download files is been deleted in temp.

How to show selected image and its name?

I am studying and simply making an user registration form where there are several fields and the user has to upload its profile picture. I use php in order to validate the data before submitting.
After hitting the submit button it validates the data and refreshes the page due to which the filled data is gone. So we use ex. value="<?php echo $name; ?>" in the input value in order to preserve the data inserted by the user. It is possible with the simple input types such as text and others but how do we preserve the data of the image and show it in the image container and show the name of the selected image in the input type file.
<!DOCTYPE html>
<!-- form -->
<?php
$nameError = $genderError = $emailError = $mobileError = $imageError = "";
$name = $gender = $email = $mobile = $image = "";
$imagePath = $_FILES['image']['name'];
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["name"])) {
$nameError = "Please provide Name";
} else {
$name = validateInput($_POST["name"]);
}
if (empty($_POST["gender"])) {
$genderError = "Please select Gender";
} else {
$gender = validateInput($_POST["gender"]);
}
if (empty($_POST["email"])) {
$emailError = "Please provide Email ID";
} else {
$email = validateInput($_POST["email"]);
}
if (empty($_POST["mobile"])) {
$mobileError = "Please provide Mobile Number";
} else {
$mobile = validateInput($_POST["mobile"]);
}
if (empty($_POST["image"])) {
$imageError = "Please provide Image";
} else {
$image = validateInput($_POST["image"]);
}
}
function validateInput($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<html lang="en" dir="ltr">
<head>
<title></title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/master.css">
<!-- style -->
<style media="screen">
.center {
text-align: center;
}
.required {
color: #ff0000;
}
form {
margin-bottom: 50px;
}
</style>
</head>
<body>
<div class="center container-fluid" style="margin: 50px;">
<h1 class="display-1">User Registration</h1>
</div>
<div class="container">
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post" enctype="multipart/form-data">
<!-- name -->
<div class="form-group">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">Name</span>
</div>
<input type="text" class="form-control" name="name" value="<?php echo $name; ?>">
</div>
<span class="required"><?php echo $nameError; ?></span>
</div>
<div class="form-group">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">Gender</span>
</div>
<select class="form-control" name="gender">
<option <?php if (isset($gender) && $gender == "") echo "selected" ?> value="">Select your gender</option>
<option <?php if (isset($gender) && $gender == "1") echo "selected" ?> value="1">Male</option>
<option <?php if (isset($gender) && $gender == "0") echo "selected" ?> value="0">Female</option>
</select>
</div>
<span class="required"><?php echo $genderError; ?></span>
</div>
<div class="form-group">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">Email</span>
</div>
<input class="form-control" type="email" name="email" value="<?php echo $email; ?>">
</div>
<span class="required"><?php echo $emailError; ?></span>
</div>
<div class="form-group">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">Mobile</span>
</div>
<input class="form-control" minlength="10" maxlength="10" type="tel" name="mobile" value="<?php echo $mobile; ?>">
</div>
<span class="required"><?php echo $mobileError; ?></span>
</div>
<!-- image container -->
<div class="form-group" id="image_container" style="display: none;">
<img src="#" id="selected_image" width="300" height="175">
</div>
<?php echo $imagePath; ?>
<?php
if (isset($imagePath) && $imagePath != "") {
echo
"<script type='text/javascript'>
document.getElementById('image_container').style.display = 'block';
document.getElementById('selected_image').src = '" . $imagePath ."';
</script>";
}
?>
<!-- image -->
<div class="form-group">
<input class="form-control" type="file" name="image" onchange="readURL(this)">
<span class="required"><?php echo $imageError; ?></span>
</div>
<!-- submit -->
<center>
<input type="submit" class="btn btn-info">
<center>
</form>
</div>
</body>
<script type="text/javascript">
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function(e) {
$('#selected_image').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
document.getElementById("image_container").style.display = "block";
}
}
</script>
</html>
Please have a look and help and suggest me.

Tablesorter do not work

I'm doing a web portal and I want to sort a table without refresh the page. When I try it with a static table it works perfect but when I do with my table that it uses information from the database it doesn't work...
This is my code, I spent almost all day searching the problem but I feel unable.
<!DOCTYPE html>
<html lang="es">
<head>
<link rel="icon" type="image/jpg" href="img/favicon.jpg" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Purchase Orders</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/ordonez.css" rel="stylesheet">
<link href="css/master.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/datepicker.css" /> <!-- Estilos calendario -->
<script type="text/javascript" src="jquery/jquery-latest.js"></script>
<script type="text/javascript" src="jquery/jquery.tablesorter.js"></script>
<script>
$(document).ready(function(){
//cuando la página se cargue convertimos la tabla con id "tabla_ordenada" en una tabla ordenable
$("#tabla_ordenada").tablesorter();
});
</script>
</head>
<body>
<?php
include("../fragmentos/cookies.php");
require("../fragmentos/es/menu.php");
?>
<div class="container ordonez min">
<?php
require_once ('../fragmentos/swap_lang.php');
require_once ('../fragmentos/funciones.php');
require_once ('../fragmentos/conexion_bbdd.php');
error_reporting(E_ALL ^ E_NOTICE);
?>
<div class="row">
<div class="col-xs-12 text-right">
<a href="panel.php" class="margen_arriba btn btn-orange hidden-lg hidden-md hidden-sm" id="">
Claims register
</a>
</div>
<div class="col-md-12 col-xs-12 col-lg-12">
<h4 class="">Filtros de búsqueda:</h4>
<form action="orders.php" method="post">
<div class="caja_gris margen_arriba">
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<div class="form-group">
<label>Estado</label>
<div class="styled-select">
<select name="status" class="form-control">
<option <?php if(!isset($_POST["status"])){echo ' selected';}?> value="0">---Sin definir---</option>
<?php
$sql = "select * from estado_envio order by estado ASC";
$resultado = $mysqli->query($sql);
while($estado = $resultado->fetch_assoc()){
?>
<option <?php if($_POST["status"]==$estado["id"]){ echo ' selected';} echo ' value="'.$estado["id"].'">'; echo $estado["estado"].'</option>';} ?>
</select>
</div>
</div>
</div>
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<div class="form-group">
<label>Nombre Proveedor</label>
<div class="styled-select">
<input type="text" class="form-control" name="name" <?php if(isset($_POST["name"])){echo ' value="'.$_POST["name"].'"';}?>>
</div>
</div>
</div>
<div class="col-lg-3 col-md-6 col-sm-6 col-xs-12">
<div class="form-group">
<label>Punto Descarga</label>
<div class="styled-select">
<select name="punto_descarga" class="form-control">
<option <?php if(!isset($_POST["punto_descarga"])){echo ' selected';}?> value="0">---Sin definir---</option>
<?php
print_r($_POST);
$sql = "select * from discharge_point order by nombre";
$resultado = $mysqli->query($sql);
while($punto = $resultado->fetch_assoc()){
?>
<option <?php if($_POST["punto_descarga"]==$punto["id"]){ echo ' selected';} echo ' value="'.$punto["id"].'">'; echo $punto["nombre"].'</option>';} ?>
</select>
</div>
</div>
</div>
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<div class="form-group">
<label>Orden Ordoñez</label>
<div class="styled-select">
<input type="text" class="form-control" name="orden_ordonez" <?php if(isset($_POST["orden_ordonez"])){echo ' value="'.$_POST["orden_ordonez"].'"';}?>>
</div>
</div>
</div>
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<div class="form-group">
<label>Artículo Proveedor</label>
<div class="styled-select">
<input type="text" class="form-control" name="art_proveedor" <?php if(isset($_POST["art_proveedor"])){echo ' value="'.$_POST["art_proveedor"].'"';}?>>
</div>
</div>
</div>
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<div class="form-group">
<label>Fecha Entrega Confirmada</label>
<div class="styled-select has-feedback">
<input data-provide="datepicker" class="form-control datepicker" name="confirm_fecha_ent"<?php if(isset($_POST["confirm_fecha_ent"])){echo ' value="'.$_POST["confirm_fecha_ent"].'"';}?> >
<span aria-hidden="true" class="glyphicon glyphicon-calendar form-control-feedback"></span>
</div>
</div>
</div>
<div class="pull-right margen_arriba_extra margen_derecha">
<input class="btn btn-orange" type="submit" name="submit">
</div>
</div>
</div>
</div>
</div>
</form>
</div>
<div id="resultados" class="col-md-12 col-xs-12 col-lg-12">
<h4 class="">Órdenes:</h4>
<div id="tabla_1" class="table-responsive">
<table id="tabla_ordenada" class="table tabla_gris">
<thead>
<tr>
<th class="text-center">Estado</th>
<th class="text-center">Nombre Proveedor</th>
<th class="text-center">Punto Descarga</th>
<th class="text-center">Orden Ordoñez</th>
<th class="text-center">Artículo Proveedor</th>
<th class="text-center">Fecha Entrega Confirmada</th>
</tr>
</thead>
<tbody>
<?php
$cont = 0;
$where = getSearchOrderConditions($_POST);
$sql = "select * from purchase_order".$where;
$sql2 = "select * from discharge_point";
$sql3 = "select * from estado_envio_en";
if($resultado = $mysqli->query($sql)){
while($orders = $resultado->fetch_assoc()){
if($cont%2==1){
echo '<tr class="fila_gris">';
}
else{
echo '<tr>';
}
$cont++;
$sql2 = "select * from estado_envio where id = '".$orders["estado"]."'";
$resultado2 = $mysqli->query($sql2);
$estado = $resultado2->fetch_assoc();
echo '<td class="text-center"><span class="al">'.$estado["estado"].'</span></td>';
echo '<td class="text-center"><span class="al">'.$orders["nombre_proveedor"].'</span></td>';
$sql2 = "select * from discharge_point where id = '".$orders["punto_descarga"]."'";
$resultado2 = $mysqli->query($sql2);
$discharge_point = $resultado2->fetch_assoc();
echo '<td class="text-center"><span class="al">'.$discharge_point["nombre"].'</span></td>';
echo '<td class="text-center"><span class="al">'.$orders["orden_ordonez"].'</span></td>';
echo '<td class="text-center"><span class="al">'.$orders["art_proveedor"].'</span></td>';
echo '<td class="text-center"><span class="al">'.$orders["confirm_fecha_ent"].'</span></td>';
echo '</tr>';
}
}
?>
<tr>
<td colspan="44">
<table width="100%" class="tabla_sin_borde">
<tbody>
<tr>
<td class="text-center">
<nav class="pull-right margen_derecha">
<ul class="pagination pull-right">
<li class="pag_2">
<a href="#" aria-label="Previous">
<span aria-hidden="true">«</span>
</a>
</li>
<li class="pag_1">1</li>
<li class="pag_2">2</li>
<li class="pag_3 active">3</li>
<li class="disabled">
<a class="pag_2" href="#" aria-label="Next">
<span aria-hidden="true">»</span>
</a>
</li>
</ul>
</nav>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php
require("../fragmentos/es/exit.php");
require("../fragmentos/es/preferences.php");
?>
<script src="js/jquery-1.9.1.js"></script>
<script src="js/bootstrap.min.js"></script>
<!-- IE 8 se adapte a resolución -->
<script type="text/javascript" src="js/respond.src.js"></script>
<script type="text/javascript" src="js/bootstrap-datepicker.js"></script>
<script>
$(document).ready(function () {
$("select[name=op]").on('change', function () {
var valor = $(this).val();
if (valor == "1") {
selectDataset(0);
}
else if (valor == "2") {
selectDataset(2);
}
else if (valor == "3") {
selectDataset(1);
}
else if (valor == "4") {
selectDataset(2);
}
else {
selectDataset(1);
}
});
})
</script>
<script>
$('#myModal').on('shown.bs.modal', function () {
$('#myInput').focus()
})
</script>
<script>
$('#buscar').click(function (e) {
e.preventDefault();
$('#resultados').removeClass("inv");
})
</script>
<script>
$('.pag_1').click(function (e) {
e.preventDefault();
$('#tabla_2').addClass("inv");
$('#tabla_1').removeClass("inv");
$('#tabla_3').addClass("inv");
})
$('.pag_2').click(function (e) {
e.preventDefault();
$('#tabla_1').addClass("inv");
$('#tabla_2').removeClass("inv");
$('#tabla_3').addClass("inv");
})
$('.pag_3').click(function (e) {
e.preventDefault();
$('#tabla_1').addClass("inv");
$('#tabla_3').removeClass("inv");
$('#tabla_2').addClass("inv");
})
</script>
<script>
$(document).ready(
function () {
$(".al").each(
function () {
$(this).attr({
"alt": $(this).text(),
"title": $(this).text()
})
}
)
}
)
</script>
<script>
$('.al').click(function (e) {
e.preventDefault();
$(this).toggleClass("al");
})
</script>
<!-- Script calendario -->
<script>
$('.datepicker').datepicker({
format: 'mm/dd/yyyy',
autoclose: true
})
</script>
<script>
$('.input-append.date').datepicker({
format: 'mm/dd/yyyy',
autoclose: true
});
</script>
<!-- Fin Script calendario -->
</body>
</html>
Excuse me and thanks for your time!

After first selection box selected, display second result based on first selection result. But not getting any result while POST

after first selection box selected, display second result based on first selection result. But not getting any result while POST. While I submit the form, system prompt
"Notice: Undefined index: location in
C:\xampp\htdocs\auditsystem\calendar\func\scheduleaction.php on line
8"
I get the result while display, only show error while submit the form.
func.php
<?php
include_once('db.php');
function getTierOne()
{
$result = mysql_query("SELECT DISTINCT * FROM outlet_type")
or die(mysql_error());
while($tier = mysql_fetch_array( $result ))
{
echo '<option value="'.$tier['id'].'">'.$tier['type'].'</option>';
}
}
if(isset($_GET['func'])) {
drop_1($_GET['drop_var']);
}
function drop_1($drop_var)
{
$result2 = mysql_query("SELECT DISTINCT * FROM outlet_type_location WHERE outlet_type_id='$drop_var'")
or die(mysql_error());
echo '<select name="location" id="tier_one" onChange="showUP(this.value)" class="form-control">
<option value=" " disabled="disabled" selected="selected">-Select Outlet location-</option>';
while($drop_2 = mysql_fetch_array( $result2 ))
{
echo '<option value="'.$drop_2['location'].'">'.$drop_2['location'].'</option>';
}
echo '</select> ';
}
?>
scheduleaction.php (here show error code)
<?php
include_once("db.php");
$auditor_id = $_POST["auditor"];
$outlet_type_id = $_POST["type"];
$date = $_POST["date"];
$outlet_location = $_POST["location"];
echo $auditor_id."<br>";
echo $outlet_type_id."<br>";
echo $outlet_location;
echo $date;
?>
Form php
<script type="text/javascript">
$(document).ready(function() {
$('#wait_1').hide();
$('#drop_1').change(function(){
$('#wait_1').show();
$('#result_1').hide();
$.get("func/func.php", {
func: "drop_1",drop_var: $('#drop_1').val()
}, function(response){
$('#result_1').fadeOut();
setTimeout("finishAjax('result_1', '"+escape(response)+"')", 0);
});
return false;
});
});
function finishAjax(id, response) {
$('#wait_1').hide();
$('#'+id).html(unescape(response));
$('#'+id).fadeIn();
}
</script>
<tr>
<label>Oulet Type:</label>
<select name="type" id="drop_1" class="form-control">
<option value="" selected="selected" disabled="disabled">-Click to select-</option>
<?php
include ("func/db.php");
include ("func/func.php");
getTierOne();
?>
</select>
<span id="wait_1" style="display: none;"><img alt="Please Wait" src="ajax-loader.gif"/></span>
<span id="result_1" style="display: none;"></span>
</tr>
try this, only mistake is, include() is present outside the form.
<?php
session_start();
include ("../connection/connect.php");
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Apex Audit System | Administration Panel</title>
<!-- Core CSS - Include with every page -->
<link href="../assets/plugins/bootstrap/bootstrap.css" rel="stylesheet" />
<link href="../assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
<link href="../assets/plugins/pace/pace-theme-big-counter.css" rel="stylesheet" />
<link href="../assets/css/style.css" rel="stylesheet" />
<link href="../assets/css/main-style.css" rel="stylesheet" />
<!-- Page-Level CSS -->
<link href="../assets/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#wait_1').hide();
$('#drop_1').change(function(){
$('#wait_1').show();
$('#result_1').hide();
$.get("func/func.php", {
func: "drop_1",drop_var: $('#drop_1').val()
}, function(response){
$('#result_1').fadeOut();
setTimeout("finishAjax('result_1', '"+escape(response)+"')", 0);
});
return false;
});
});
function finishAjax(id, response) {
$('#wait_1').hide();
$('#'+id).html(unescape(response));
$('#'+id).fadeIn();
}
</script>
<body>
<?php
include_once("../assets/template/mainlinks2.php");
include_once("../assets/template/sidebar3.php");
?> <!-- page-wrapper -->
<div id="page-wrapper">
<div class="row">
<!-- page header -->
<div class="col-lg-12">
<h1 class="page-header">Setup New Schedule</h1>
</div>
<!-- end page header -->
</div>
<div class="row">
<div class="col-lg-12">
<!-- Advanced Tables -->
<div class="panel panel-default">
<div class="panel-heading">
Assign New Schedule
</div>
<div class="panel-body">
<div class="table-responsive">
<form action="func/scheduleaction.php" role="form" method="POST" name="form">
<table>
<div class="form-group">
<?php
include ("func/db.php");
include ("func/func.php");
?>
<tr>
<label>Auditor Name:</label>
<select class="form-control" name="auditor">
<?php
$result = $db->query("SELECT * FROM auditor");
while($row = mysqli_fetch_array($result))
{
echo '<option value="'.$row["id"].'">'.$row["auditor_name"].'</option>';
}
echo "</select>";
?>
</tr>
<tr>
<label>Oulet Type:</label>
<select name="type" id="drop_1" class="form-control">
<option value="" selected="selected" disabled="disabled">-Click to select-</option>
<?php
getTierOne();
?>
</select>
<span id="wait_1" style="display: none;"><img alt="Please Wait" src="ajax-loader.gif"/></span>
<span id="result_1" style="display: none;"></span>
</tr>
<tr>
<label>Audit Date:</label>
<input type="date" name="date" class="form-control" required="required">
</tr>
<br>
<tr>
<td><button type="submit" class="btn btn-primary">Submit Button</button></td>
<td><button type="reset" class="btn btn-success">Reset Button</button></td>
</tr>
</div>
</form>
</table>
</div>
</div>
</div>
<!--End Advanced Tables -->
</div>
</div>
</div>
<!-- end page-wrapper -->
</div>
<!-- end wrapper -->
<!-- Core Scripts - Include with every page -->
<script src="../assets/plugins/jquery-1.10.2.js"></script>
<script src="../assets/plugins/bootstrap/bootstrap.min.js"></script>
<script src="../assets/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="../assets/plugins/pace/pace.js"></script>
<script src="../assets/scripts/siminta.js"></script>
</body>
</html>
<?php
session_start();
include ("../connection/connect.php");
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Apex Audit System | Administration Panel</title>
<!-- Core CSS - Include with every page -->
<link href="../assets/plugins/bootstrap/bootstrap.css" rel="stylesheet" />
<link href="../assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
<link href="../assets/plugins/pace/pace-theme-big-counter.css" rel="stylesheet" />
<link href="../assets/css/style.css" rel="stylesheet" />
<link href="../assets/css/main-style.css" rel="stylesheet" />
<!-- Page-Level CSS -->
<link href="../assets/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#wait_1').hide();
$('#drop_1').change(function(){
$('#wait_1').show();
$('#result_1').hide();
$.get("func/func.php", {
func: "drop_1",drop_var: $('#drop_1').val()
}, function(response){
$('#result_1').fadeOut();
setTimeout("finishAjax('result_1', '"+escape(response)+"')", 0);
});
return false;
});
});
function finishAjax(id, response) {
$('#wait_1').hide();
$('#'+id).html(unescape(response));
$('#'+id).fadeIn();
}
</script>
<body>
<?php
include ("func/db.php");
include ("func/func.php");
?>
<?php
include_once("../assets/template/mainlinks2.php");
include_once("../assets/template/sidebar3.php");
?> <!-- page-wrapper -->
<div id="page-wrapper">
<div class="row">
<!-- page header -->
<div class="col-lg-12">
<h1 class="page-header">Setup New Schedule</h1>
</div>
<!-- end page header -->
</div>
<div class="row">
<div class="col-lg-12">
<!-- Advanced Tables -->
<div class="panel panel-default">
<div class="panel-heading">
Assign New Schedule
</div>
<div class="panel-body">
<div class="table-responsive">
<form action="func/scheduleaction.php" role="form" method="POST" name="form">
<table>
<div class="form-group">
<tr>
<label>Auditor Name:</label>
<select class="form-control" name="auditor">
<?php
$result = $db->query("SELECT * FROM auditor");
while($row = mysqli_fetch_array($result))
{
echo '<option value="'.$row["id"].'">'.$row["auditor_name"].'</option>';
}
echo "</select>";
?>
</tr>
<tr>
<label>Oulet Type:</label>
<select name="type" id="drop_1" class="form-control">
<option value="" selected="selected" disabled="disabled">-Click to select-</option>
<?php
getTierOne();
?>
</select>
<span id="wait_1" style="display: none;"><img alt="Please Wait" src="ajax-loader.gif"/></span>
<span id="result_1" style="display: none;"></span>
</tr>
<tr>
<label>Audit Date:</label>
<input type="date" name="date" class="form-control" required="required">
</tr>
<br>
<tr>
<td><button type="submit" class="btn btn-primary">Submit Button</button></td>
<td><button type="reset" class="btn btn-success">Reset Button</button></td>
</tr>
</div>
</form>
</table>
</div>
</div>
</div>
<!--End Advanced Tables -->
</div>
</div>
</div>
<!-- end page-wrapper -->
</div>
<!-- end wrapper -->
<!-- Core Scripts - Include with every page -->
<script src="../assets/plugins/jquery-1.10.2.js"></script>
<script src="../assets/plugins/bootstrap/bootstrap.min.js"></script>
<script src="../assets/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="../assets/plugins/pace/pace.js"></script>
<script src="../assets/scripts/siminta.js"></script>
</body>
</html>

Unable to show JQuery datepicker on my php page

I followed the source code on Jquery page to get a datepicker for my php page, but I cant get the calendar out. I think the Jquery is not loading for this page, can anyone tell me why? Thanks you
Here is my source code: I have my own designs for class element.
<html lang="en">
<head>
<meta charset="utf-8">
<title>Admin</title>
<link rel="stylesheet" type="text/css" href="css/style.css" media="screen" />
<link rel="stylesheet" type="text/css" href="css/navi.css" media="screen" />
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<link href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" rel="stylesheet" />
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript">
$(function(){
$(".box .h_title").not(this).next("ul").hide("normal");
$(".box .h_title").not(this).next("#home").show("normal");
$(".box").children(".h_title").click( function() { $(this).next("ul").slideToggle(); });
});
</script>
<script src="ckeditor/ckeditor.js"></script>
<script type="text/javascript">
$(function() {
$( "#datepicker" ).datepicker();
});
</script>
</head>
<script>
function validateForm()
{
var x=document.forms["my_form"]["title"].value;
var y=document.forms["my_form"]["author"].value;
var z=document.forms["my_form"]["keywords"].value;
var type=document.forms["my_form"]["category"].value;
if (x=="" || y=="" || z =="" || type=="")
{
alert("Please fill in the required fields");
return false;
}
}
</script>
<body>
<div class="wrap">
<div id="header">
<div id="top">
<div class="left">
<p>Welcome, <strong><?php echo $_SESSION['login']?> </strong> [ logout ]</p>
</div>
</div>
<div id="nav">
<ul>
<li class="upp">Manage Content
<ul>
<li>› Admin Home</li>
<li>› Manage Posts</li>
<li>› Manage User</li>
</ul>
</li>
</ul>
</div>
</div>
<div id="content">
<div id="sidebar">
<div class="box">
<div class="h_title">› Manage content</div>
<ul id="home">
<li class="b1"><a class="icon view_page" href="admin.php">Admin Home</a></li>
<li class="b2"><a class="icon report" href="viewPosts.php">Add Posts</a></li>
</ul>
</div>
<div class="box">
<div class="h_title">› Category</div>
<ul id="home">
<?php
include("includes/connect.php");
$sql = "SELECT post_type, COUNT(*) AS num FROM post WHERE post_status ='New' GROUP BY post_type";
$result = mysql_query($sql);
while($Cat_row= mysql_fetch_array($result)){
$type =$Cat_row['post_type'];
$number = $Cat_row['num'];
?>
<li class="b2"><a class="icon category" href="postType.php?cat=<?php echo $type?>"><?php echo $type." (".$number.")"?></a></li>
<?php }?>
</ul>
</div>
<div class="box">
<div class="h_title">› Archives</div>
<ul id="home">
<?php
include("includes/connect.php");
$sql_arc ="SELECT post_type, COUNT(*) AS numb FROM post WHERE post_status='Old' GROUP BY post_type";
$result_arc = mysql_query($sql_arc);
while($Arc_row= mysql_fetch_array($result_arc)){
$type_arc =$Arc_row['post_type'];
$number_arc = $Arc_row['numb'];
?>
<li class="b1"><a class="icon config" href="postArchive.php?type=<?php echo $type_arc?>"><?php echo $type_arc." (".$number_arc.")"?></a></li>
<?php }?>
</ul>
</div>
</div>
<div id="main">
<div class="full_w">
<div class="h_title">Add new Posts</div>
<form method="post" action="viewPosts.php" name="my_form" enctype="multipart/form-data" onsubmit="return validateForm()">
<div class="element">
<label >Title <span class="red">*</span></label>
<input type="text" name="title" class="text err" />
</div>
<div class="element">
<label>Author <span class="red">*</span></span></label>
<input type="text" name="author" class="text err" />
</div>
<div class="element">
<label>Keywords <span class="red">*</span></label>
<input type="text" name="keywords" class="text err" />
</div>
<div class="element">
<input type="text" id="datepicker">
</div>
<div class="element">
<label>Category <span class="red">*</span></label>
<select name="category" class="err">
<option value="">-- select category</option>
<option value="Class">Class</option>
<option value="Facilities">Facilities</option>
<option value="Services">Services</option>
<option value="Announcement">Announcement</option>
<option value="Promotions">Promotions</option>
<option value="News">News</option>
<option value="Uncategorized">Uncategorized</option>
</select>
</div>
<div class="element">
<label for="content">Page content <span>(required)</span></label>
<textarea id="editor1" name="content" class="textarea" rows="10"></textarea>
</div>
<script>
// Replace the <textarea id="editor1"> with a CKEditor
// instance, using default configuration.
CKEDITOR.replace( 'editor1',
{
// Load the German interface.
language: ''
});
</script>
<div class="entry">
<button type="submit" name="submit" class="add">Save Post</button>
<button class="cancel" type="reset" >Cancel</button>
</div>
</form>
</div>
</div>
<div class="clear"></div>
</div>
<div id="footer">
<div class="left">
<p>NUS Staff Club Admin Panel</p>
</div>
</div>
</div>
</body>
</html>
<?php
include("includes/connect.php");
if(isset($_POST['submit'])){
$post_title = $_POST['title'];
$post_date = date("Y-m-d");
$post_author = $_POST['author'];
$post_keywords = $_POST['keywords'];
$post_type = $_POST['category'];
$post_content = $_POST['content'];
$post_status = 'New';
// $post_image = $_FILES['image']['name'];
// $image_temp = $_FILES['image']['tmp_name'];
/*if(empty($post_title) || empty($post_author) || empty($post_keywords) || empty($post_type) || empty($post_content) ){
exit();
}*/
// else{
// move_uploaded_file($image_temp,"../image/$post_image");
$insert_query = "insert into post (post_title,post_date,post_author,post_keywords,post_type,post_content,post_status) values ('$post_title','$post_date','$post_author'
,'$post_keywords','$post_type','$post_content','$post_status')";
if(mysql_query($insert_query)){
echo "<script>alert('Post has been pushlished successfully')</script>";
echo "<script>window.open('admin.php','_self')</script>";
}
else{ echo "<script>alert('failed')</script>";}
// }
}
?>
<?php }?>
You're calling your element before it's created...
replace
$(function() {
$( "#datepicker" ).datepicker();
});
by
$().ready(function() {
$( "#datepicker" ).datepicker();
})
;

Categories

Resources