$rec_limit = 20 ;
$page_name = "/search";
$uri = $_SERVER['REQUEST_URI'];
$url_explode = explode("/", $uri);
if (count($url_explode) > 2) {
/* if( isset($_GET{'page'} ) ) {
$page = $_GET{'page'} + 1;
$offset = $rec_limit * $page ;
}else {
$page = 0;
$offset = 0;
}
*/
$lastElement = $url_explode[count($url_explode) - 2];
if (is_numeric($lastElement)) {
$page = $lastElement;// + 1;
$offset = 0;
if ($lastElement > 0)
{
$offset = $rec_limit * ($page - 1) ;
}
}
else
{
$page = 1;
$offset = 0;
}
}
?>
$search = "";
$description = "";
$recordId = "";
if (!$link = mysqli_connect('localhost', 'wp3hway', '6.bp6US-75')) {
echo 'Could not connect to mySql';
exit;
}
if (!mysqli_select_db($link,'hiwaydist_hwphotoitem')) {
echo 'Could not select database';
exit;
}
if (isset($_POST["search"])) {
$search = $_POST["search"];
}
elseif (isset($_GET["search"])) {
$search = $_GET["search"];
}
/* Get total number of records */
$sql = "select count(id) from PhotoItem ";
if (strlen($search) > 0)
{
$sql .= "where (LDescription like '%$search%' or ProductNum like '%$search%' or SDescription like '%$search') and DeletedInSBTFlag = 0 ";
}
$retval = mysqli_query($link, $sql);
if(! $retval ) {
die('Could not get data: ' . mysqli_error());
}
$row = mysqli_fetch_array($retval, MYSQL_NUM );
$rec_count = $row[0];
$left_rec = $rec_count - ($page * $rec_limit);
$sql = "select id, ProductNum, SDescription, LDescription from PhotoItem where DeletedInSBTFlag = 0 ";
if (strlen($search) > 0)
{
$sql .= "and (LDescription like '%$search%' or ProductNum like '%$search%' or SDescription like '%$search') ";
}
if (isset($offset))
{
$sql .= "order by ProductNum asc LIMIT $offset, $rec_limit";
}
else
{
$sql .= "order by ProductNum asc LIMIT 0, $rec_limit";
}
// echo $sql;
$result = mysqli_query($link, $sql);
if (!$result) {
echo "DB Error, could not query the database\n";
echo 'MySQL Error: ' . mysql_error();
exit;
}
?>
No results found
Description