Good day all, the code posted below is working fine for me. What I need help with is, I want the search form to become hidden the moment the page loads the results to be displayed. I know nothing about Jquery or Javascript. Please how do I do this? My code for the search page is below. Thanks
<?php
@session_start();
if(isset($_SESSION['userName'])) $_SESSION['userName'];
if(isset($_SESSION['passWord'])) $_SESSION['passWord'];
if(!isset($_SESSION['userName']))
{
header('Location: ../index.php');
}
require_once '../classes/Config.php';
$result = new ECConfig();
$result2 = new ECConfig();
$result->getSiteName();
$result2->getSiteNickName();
?>
<!DOCTYPE html>
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title><?php echo $result->getSiteName(); ?> | Administrator</title>
<link href="../css/normalize.css" rel="stylesheet" />
<link href="../css/foundation.css" rel="stylesheet" />
<link href="../main.css" rel="stylesheet" type="text/css" media="all">
<link href="../css/pagination.css" rel="stylesheet" type="text/css" />
<link href="../css/B_blue.css" rel="stylesheet" type="text/css" />
<script src="../js/vendor/custom.modernizr.js"></script>
</head>
<body>
<?php
if (isset($_GET['action']) and $_GET['action'] == 'search stores')
{
//connect to the database
if(include_once ('DatabaseManager.php'));
$conn = DatabaseManager::getConnection();
//get the function
include_once ('function.php');
$page = (int) (!isset($_GET["page"]) ? 1 : $_GET["page"]);
$limit = 10;
$startpoint = ($page * $limit) - $limit;
if ($_GET['storeOwnerFirstName'] != '')
{
$storeOwnerFirstName = trim($_GET['storeOwnerFirstName']);
}
if ($_GET['storeOwnerLastName'] != '')
{
$storeOwnerLastName = trim($_GET['storeOwnerLastName']);
}
if ($_GET['assignedID'] != '')
{
$assignedID = trim($_GET['assignedID']);
}
if ($_GET['state'] != '')
{
$state = trim($_GET['state']);
}
if ($_GET['country'] != '')
{
$country = trim($_GET['country']);
}
$statement = "store WHERE ";
if(isset($storeOwnerFirstName)){
$statement .= "storeOwnerFirstName LIKE '%" . $storeOwnerFirstName . "%' AND ";
}
if(isset($storeOwnerLastName)){
$statement .= "storeOwnerLastName LIKE '%" . $storeOwnerLastName . "%' AND ";
}
if(isset($assignedID)){
$statement .= "assignedID LIKE '%" . $assignedID . "%' AND ";
}
if(isset($state)){
$statement .= "state LIKE '%" . $state . "%' AND ";
}
if(isset($country)){
$statement .= "country LIKE '%" . $country . "%' AND ";
}
$statement .= '1';
$query = $conn->query("SELECT * FROM {$statement} ORDER BY id DESC LIMIT {$startpoint} , {$limit}");
$storeRegister = $conn->query("SELECT * FROM {$statement}");
$store = $storeRegister->rowCount();
}
?>
<div class="contain-to-grid">
<div class="top-bar text-center">
<h3 class="dammy1"><?php echo $result->getSiteName(); ?></h3>
<h5 class="subheader"><?php echo $result->getSiteNickName(); ?></h5>
</div>
</div>
<!-- The part above takes care of the banner region -->
<div class="row">
<div class="breadcrumbs">
<div class="large-7 columns">
<a href="../homepage.php">Main Home</a> || <a href="../administrator/index.php">Admin Home</a>
</div>
<div class="large-5 columns">
You are logged in as <?php if(isset($_SESSION['userName'])) echo $_SESSION['userName']; ?> || Log Out <a href="index.php?action=logout" title="Sign out"><img src="../img/quit.png" alt="Log Out" /></a>
</div>
</div>
</div>
<br/>
<div class="row">
<div class="large-9 columns">
<?php include 'storeConsole.php'; ?>
<p class="searchResult">
<?php
if(isset($store)) {
if($store == 0)
{
echo 'No store was found during the search';
}
if($store == 1)
{
echo '1 store was found during the search.';
}
if($store > 1)
{
echo "$store stores were found during the search ";
}
}
?>
</p>
<form action="" method="get">
<fieldset>
<legend>Search for a store or stores</legend>
<div class="row">
<div class="large-4 columns">
<label>Store Owner's First Name</label>
</div>
<div class="large-5 columns">
<input type="text" name="storeOwnerFirstName" value="" />
</div>
<div class="large-3 offset-3 columns"> </div>
</div>
<div class="row">
<div class="large-4 columns">
<label>Store Owner's Last Name</label>
</div>
<div class="large-5 columns">
<input type="text" name="storeOwnerLastName" value="" />
</div>
<div class="large-3 offset-3 columns"> </div>
</div>
<div class="row">
<div class="large-4 columns">
<label>Assigned ID</label>
</div>
<div class="large-5 columns">
<input type="text" name="assignedID" value="" />
</div>
<div class="large-3 offset-3 columns"> </div>
</div>
<div class="row">
<div class="large-4 columns">
<label>State/Province</label>
</div>
<div class="large-5 columns">
<input type="text" name="state" value="" />
</div>
<div class="large-3 offset-3 columns"> </div>
</div>
<div class="row">
<div class="large-4 columns">
<label>Country</label>
</div>
<div class="large-5 columns">
<input type="text" name="country" value="" />
</div>
<div class="large-3 offset-3 columns"> </div>
</div>
<div class="row">
<div class="large-7 columns">
<input type="hidden" name="action" value="search stores" />
<input type="submit" value="Search" class="button round" />
</div>
<div class="large-5 offset-5 columns"> </div>
</div>
</fieldset>
</form>
<?php if(isset($query)): ?>
<div class="large-7 columns">How many result do you want to display per page? </div>
<div class="large-3 columns">
<form action="" method="get">
<select name="limit">
<option value="5">5</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
<option value="25">25</option>
<option value="50">50</option>
<option value="100">100</option>
</select>
</form>
</div>
<div class="large-2 columns"><input type="submit" value="Go" class="button myconsole2 radius"/></div>
<div class="large-5 columns panel"><h5>Store Owner's Full Name</h5></div>
<div class="large-3 columns panel"><h5>Assigned ID</h5></div>
<div class="large-4 columns panel"><h5>Action</h5></div>
<?php foreach($query as $i=>$store): ?>
<div class="large-5 columns"><?php echo htmlentities($store['title'], ENT_COMPAT, 'UTF-8') . ' ' .htmlentities($store['storeOwnerFirstName'], ENT_COMPAT, 'UTF-8') . ' ' . htmlentities($store['storeLastName'], ENT_COMPAT, 'UTF-8'); ?></div>
<div class="large-3 columns"><?php echo htmlentities($store['assignedID'], ENT_COMPAT, 'UTF-8'); ?></div>
<div class="large-4 columns">
<form action="index.php" method="post">
<div>
<input type="hidden" name="id" value="<?php echo htmlentities($store['id']); ?>"/>
<input type="hidden" name="action" value="View Store Detail"/><input type="submit" value="View Detail" class="button myconsole2 radius"/>
</div>
</form>
</div>
<hr/>
<?php endforeach; ?>
<?php endif; ?>
<div class="large-12 columns paginate"><?php if(isset($query)) echo pagination($statement, $limit, $page); ?></div>
</div>
<div class="large-3 columns">
<?php include 'mainmenu.php'; ?>
</div>
</div><!--closing tag for the first row -->
<br/>
<br/>
<br/>
<!-- Footer -->
<div class="wrapper row2">
<div class="row">
<br/>
</div>
</div>
<div class="wrapper row4">
<div class="row">
<div class="large-12 columns text-center">
<p> © <?php echo date('Y'); ?> All Rights Reserved.</p>
</div>
</div>
</div>
</body>
</html>