这是一次简单的分页尝试。我想我会按照我所知道的去做。现在页面运行良好,我可以滚动浏览 LIMIT $startfrom
、$displayto(amount)
问题是第一页显示图像,但是一旦我单击按钮在图像中移动,我就没有看到图像?但当我点击返回时,我确实这么做了,但只有 3 个。
我真的不确定发生了什么,但分页结果应该是这样的(0-5, 5-5, 10,5 15,5 20,5)
等。 .但在 0,5 之后 - 没有更多图像。
我也通过 FORM
发布 $variables
。
另外,当我浏览DEV时,我发现第1页之后就没有动态图像了。但 LIMIT 是正确的,应该按预期显示,只是由于某些奇怪的原因没有图像。我认为它与手动调用 MYSQ 来再次运行数据库有关,但我不确定为什么它不会通过 FORM POST 执行此操作,因为它会调用整个脚本和页面。
<?php
//
include ("conect.php");
if (isset($_POST['startfrom'])) {
$startfrom = htmlentities($_POST['startfrom'] ); };
if (isset($_POST['displayto'])) {
$displayto = htmlentities($_POST['displayto'] ); };
if (isset($_POST['resultcheck'])) {
$resultcheck = htmlentities($_POST['resultcheck'] ); };
if (isset($_POST['maxresults'])) {
$maxresults = htmlentities($_POST['maxresults'] ); };
if (empty($maxresults)) {$maxresults=5; }
if (empty($startfrom)) {$startfrom=0; };
if (empty($displayto)) {$displayto=5; };
if (empty($resultcheck)) {$resultcheck=0; };
if (!empty($resultcheck)) {$resultcheck=$resultcheck; };
if (!empty($startfrom)) {$startfrom=$startfrom; };
if (!empty($displayto)) {$displayto=$displayto; };
if (!empty($maxresults)) {$maxresults=$maxresults; }
if (isset($_POST['searchfor'])) {
$search = htmlentities($_POST['searchfor'] ); }
function ($search) {
echo htmlspecialchars($search, ENT_QUOTES, 'utf-8');
};
$search = mysqli_real_escape_string($conn, $search);
$search = filter_var($search, FILTER_SANITIZE_STRING);
if (empty($search)) { $search="";};
if (isset($_POST['location'])) {
$location = htmlentities($_POST['location'] ); }
function ($location) {
echo htmlspecialchars($location, ENT_QUOTES, 'utf-8');
};
$location = mysqli_real_escape_string($conn, $location);
$location = filter_var($location, FILTER_SANITIZE_STRING);
//$location = strtolower($location);
if (empty($location)) { $location="";};
if (isset($_POST['postcode'])) {
$postcode = htmlentities($_POST['postcode'] ); }
function ($postcode) {
echo htmlspecialchars($postcode, ENT_QUOTES, 'utf-8');
};
$postcode = mysqli_real_escape_string($conn, $postcode);
$postcode = filter_var($postcode, FILTER_SANITIZE_STRING);
if (empty($postcode)) { $postcode="";};
if (isset($_POST['price'])) {
$price = htmlentities($_POST['price'] ); }
function ($price) {
echo htmlspecialchars($price, ENT_QUOTES, 'utf-8');
};
$price = mysqli_real_escape_string($conn, $price);
$price = filter_var($price, FILTER_SANITIZE_STRING);
if (empty($price)) { $price="";};
if (isset($_POST['catagory'])) {
$catagory = htmlentities($_POST['catagory'] ); }
function ($catagory) {
echo htmlspecialchars($catagory, ENT_QUOTES, 'utf-8');
};
$catagory = mysqli_real_escape_string($conn, $catagory);
$catagory = filter_var($catagory, FILTER_SANITIZE_STRING);
if (empty($catagory)) {$catagory="";};
if ($resultcheck<1) {
if (empty($postcode)) {
if (!empty($search) && !empty($location)) {
$sql = "SELECT * FROM testdata
WHERE price LIKE '%%$price%%' AND type LIKE '%%$catagory%%' AND locate LIKE '%%$location%%' AND title LIKE '%%$search%%'
OR price LIKE '%%$price%%' AND locate='$location' AND title LIKE '%%$search%%'
OR price LIKE '%%$price%%' AND locate LIKE '%%$location%%' AND type LIKE '%%$search%%'
OR price LIKE '%%$price%%' AND locate='$location' AND type LIKE '%%$search%%'
";
};
if (empty($search) && !empty($location)) {
$sql = "SELECT * FROM testdata
WHERE price LIKE '%%$price%%' AND type LIKE '%%$catagory%%' AND locate LIKE '%%$location%%' OR locate ='%%$location%%' ORDER BY price DESC
";
};
if (empty($search) && empty($location)) {
$sql = "SELECT * FROM testdata WHERE price LIKE '%%$price%%' AND type LIKE '%%$catagory%%' ORDER BY price DESC
";
};
if (!empty($search) && empty($location)) {
$sql = "SELECT * FROM testdata
WHERE price LIKE '%%$price%%' AND type LIKE '%%$catagory%%' AND title LIKE '%%$search%%' OR info LIKE '%%$search%%' ORDER BY price DESC
";
};
};
if (!empty($postcode)) {
if (!empty($search) && !empty($location)) {
$sql = "SELECT * FROM testdata
WHERE price LIKE '%%$price%%' AND type LIKE '%%$catagory%%' AND locate LIKE '%%$location%%' AND title LIKE '%%$search%%' AND postcode LIKE '%%$postcode%%'
OR price LIKE '%%$price%%' AND locate='$location' AND title LIKE '%%$search%%' AND postcode LIKE '%%$postcode%%'
OR price LIKE '%%$price%%' AND locate LIKE '%%$location%%' AND type LIKE '%%$search%%' AND postcode LIKE '%%$postcode%%'
OR price LIKE '%%$price%%' AND locate='$location' AND type LIKE '%%$search%%' AND postcode LIKE '%%$postcode%%'
ORDER BY price DESC
";
};
if (empty($search) && !empty($location)) {
$sql = "SELECT * FROM testdata
WHERE price LIKE '%%$price%%' AND type LIKE '%%$catagory%%' AND locate LIKE '%%$location%%' AND postcode LIKE '%%$postcode%%'
OR price LIKE '%%$price%%' AND locate='%%$location%%' AND postcode LIKE '%%$postcode%%'
ORDER BY price DESC
";
};
if (empty($search) && empty($location)) {
$sql = "SELECT * FROM testdata
WHERE price LIKE '%%$price%%' AND type LIKE '%%$catagory%%' AND postcode LIKE '%%$postcode%%' OR postcode='%%$postcode%%'
ORDER BY price DESC
";
};
if (!empty($search) && empty($location)) {
$sql = "SELECT * FROM testdata
WHERE price LIKE '%%$price%%' AND type LIKE '%%$catagory%%' AND title LIKE '%%$search%%' AND postcode LIKE '%%$postcode%%'
OR info LIKE '%%$search%%' AND postcode LIKE '%%$postcode%%'
ORDER BY price DESC
";
};
};
$result = $conn->query($sql);
$row_cnt = $result->num_rows;
$maxresults=$row_cnt;
$resultcheck="1";
}; //if empty resultcheck
if ($resultcheck=1 OR $resultcheck>1) {
if (empty($postcode)) {
if (!empty($search) && !empty($location)) {
$sql = "SELECT * FROM testdata
WHERE price LIKE '%%$price%%' AND type LIKE '%%$catagory%%' AND locate LIKE '%%$location%%' AND title LIKE '%%$search%%'
OR price LIKE '%%$price%%' AND locate='$location' AND title LIKE '%%$search%%'
OR price LIKE '%%$price%%' AND locate LIKE '%%$location%%' AND type LIKE '%%$search%%'
OR price LIKE '%%$price%%' AND locate='$location' AND type LIKE '%%$search%%' ORDER BY price DESC LIMIT $startfrom,$displayto
";
};
if (empty($search) && !empty($location)) {
$sql = "SELECT * FROM testdata
WHERE price LIKE '%%$price%%' AND type LIKE '%%$catagory%%' AND locate LIKE '%%$location%%' OR locate ='%%$location%%' ORDER B price DESC LIMIT $startfrom,$displayto
";
};
if (empty($search) && empty($location)) {
$sql = "SELECT * FROM testdata WHERE price LIKE '%%$price%%' AND type LIKE '%%$catagory%%' ORDER BY price DESC LIMIT $startfrom,$displayto
";
};
if (empty($location) && !empty($search))";
$sql = "SELECT * FROM testdata
WHERE price LIKE '%%$price%%' AND type LIKE '%%$catagory%%' AND title LIKE '%%$search%%' OR info LIKE '%%$search%%' ORDER BY price DESC LIMIT $startfrom,$displayto
";
};
};
if (!empty($postcode)) {
if (!empty($search) && !empty($location)) {
//echo "1. if (!empty($search) && !empty($location)) ";
$sql = "SELECT * FROM testdata
WHERE price LIKE '%%$price%%' AND type LIKE '%%$catagory%%' AND locate LIKE '%%$location%%' AND title LIKE '%%$search%%' AND postcode LIKE '%%$postcode%%'
OR price LIKE '%%$price%%' AND locate='$location' AND title LIKE '%%$search%%' AND postcode LIKE '%%$postcode%%'
OR price LIKE '%%$price%%' AND locate LIKE '%%$location%%' AND type LIKE '%%$search%%' AND postcode LIKE '%%$postcode%%'
OR price LIKE '%%$price%%' AND locate='$location' AND type LIKE '%%$search%%' AND postcode LIKE '%%$postcode%%'
ORDER BY price DESC LIMIT $startfrom,$displayto
";
};
if (empty($search) && !empty($location)) {
$sql = "SELECT * FROM testdata
WHERE price LIKE '%%$price%%' AND type LIKE '%%$catagory%%' AND locate LIKE '%%$location%%' AND postcode LIKE '%%$postcode%%'
OR price LIKE '%%$price%%' AND locate='%%$location%%' AND postcode LIKE '%%$postcode%%' ORDER BY price DESC LIMIT $startfrom,$displayto
";
};
if (empty($search) && empty($location)) {
$sql = "SELECT * FROM testdata
WHERE price LIKE '%%$price%%' AND type LIKE '%%$catagory%%' AND postcode LIKE '%%$postcode%%' OR postcode='%%$postcode%%' ORDER BY price DESC LIMIT $startfrom,$displayto
";
};
if (!empty($search) && empty($location)) {
$sql = "SELECT * FROM testdata
WHERE price LIKE '%%$price%%' AND type LIKE '%%$catagory%%' AND title LIKE '%%$search%%' AND postcode LIKE '%%$postcode%%'
OR info LIKE '%%$search%%' AND postcode LIKE '%%$postcode%%' ORDER BY price DESC LIMIT $startfrom,$displayto
";
};
};
$result = $conn->query($sql);
$resultcheck=2;
};
echo" <div class='searchresults'> ";
printf("Search Results for {$search} in {$catagory} Within {$location} & Totals %d results {$displayto}&{$startfrom} <br><br>", $maxresults);
echo" </div>";
while($row = mysqli_fetch_assoc($result)) { // while($row = mysqli_fetch_assoc($result)) {
$vid = $row['id']; //<!---important is Video ID and needed for video click selection---->
$type = $row['type'];
$id = $row['id'];
$vidd= $row['id']-0.01;
$pidd= $row['id']-0.02;
$name = $row['Name'];
$image = $row['image'];
$info = $row['info'];
$phone = $row['phone'];
$title = $row['title'];
$locate = $row['locate'];
$postcoded = $row['postcode'];
$price = $row['price'];
$videos = $row['videos'];
$date = $row['stamp'];
$type = $row['type'];
$showinglocate=$row['id']-0.03;
$showingphone=$row['id']-0.04;
echo"
<div class='floater'>
<div style='position:absolute; top:0%; left:0%; width:100%; height:99%; border-radius: 1vw; box-shadow: 1px 1px 3px 1px #aaa; background-color:white; overflow:hidden;'>
";
if (empty($videos) && empty($image)) {
echo "<img src='image/blank.png' style='position:absolute; top:18%; left:10%; width:80%; height:68%; opacity:0.5; transform: scale(1.0,1.1);'>
"; }
if (!empty($videos)) {
echo "
<video id='$vidd' title='{$row['title']} {$row['locate']}' style='position:absolute; top:18%; left:0%; width:100%; height:60%; transform: scale(1.0,1.1);' preload='metadata' controls='controls'>
<source src='vid/{$row['videos']}.mp4' type='video/mp4'>
<source src='vid/{$row['videos']}.mp4' type='video/ogg'>
<source src='vid/{$row['videos']}.mp4' type='video/webm'>
</video >
<div id='vidicon' title='Video's' class='vidicon' ondblclick='controlshowvid($vidd , $pidd);' ><img src='pageimages/vidicon.jpg' style='position:absolute; top:0%; left:0%; width:100%; height:100%; z-index:1; cursor:hand;'></div>
"; }
if (!empty($image)) {
echo "<img id='$pidd' src='image/{$row['image']}' style='position:absolute; top:18%; left:0%; width:100%; height:60%; transform: scale(1.0,1.1);'>
<div id='pictureicon' title='Pictures' class='pictureicon' ondblclick='controlshowimage($vidd , $pidd);'><img src='pageimages/pictureicon.jpg' style='position:absolute; top:0%; left:0%; width:100%; height:100%; z-index:1; cursor:hand;'></div>
"; }
echo "
<div id='displaytitle' style='position:absolute; top:3%; left:1%; width:100%;'><font style='font-size:1.4em;color:blue'><center>{$row['title']}</center></div></font>
<div id='displaystamp' title='{$row['stamp']}'style='position:absolute; top:9.0%; left:3%; width:30%; text-align:left;'><font style='color:grey; font-size:0.6em;'>{$row['stamp']}</div><br></font>
<div id='displaypostcode' title='{$row['postcode']}' style='position:absolute; top:9%; left:84.8%; width:16.2%; '><font style='color:grey; font-size:0.7em;'>{$row['postcode']}</div><br></font>
<div id='displayprice' style='position:absolute; top:90%; left:2%; text-align:center; border-radius: 1vw; box-shadow: 1px 1px 2px 1px #aaa;'><font style='color:blue;'><center><strong>£{$row['price']}</strong></center></div>
<div id='$showinglocate' title='{$row['postcode']}' style='position:absolute; top:82%; left:0%; width:100%; Z-index:15; cursor:hand;' ondblclick='changeshowdetail($showinglocate, $showingphone)' ><font style='color:black'><center><strong>{$row['locate']}</strong></center></div>
<div id='$showingphone' title='{$row['Name']}' style='position:absolute; top:82%; left:0%; width:100%; visibility:hidden; cursor:hand; ' ondblclick='changeshowdetail2($showinglocate,$showingphone)' ><font style='color:black'><center><strong>{$row['phone']}</strong></center></div>
<div id='showwhole' class='showwhole' title='Click to View' ondblclick='' ><font style='font-size:0.8em; #ddd'>View Full Page</font></div>
</div>
</div>
";
}
?>
</div>
</div>
</div>
<div class="footer">
<form id='sendpaginationforward' action='linkdsearch.php' method='POST' enctype='multipart/form-data' >
<input type='hidden' type='text' name='startfrom' value='<?php echo $startfrom = $startfrom +5 ?>' />
<input type='hidden' type='text' name='displayto' value='<?php echo $displayto = 5 ?>' />
<input type='hidden' type='text' name='searchfor' value='<?php echo $search ?>' />
<input type='hidden' type='text' name='price' value='<?php echo $price ?>' />
<input type='hidden' type='text' name='catagory' value='<?php echo $catagory ?>' />
<input type='hidden' type='text' name='location' value='<?php echo $location ?>' />
<input type='hidden' type='text' name='resultcheck' value='<?php echo $resultcheck ?>' />
<input type='hidden' type='text' name='postcode' value='<?php echo $postcode ?>' />
<input type='hidden' type='text' name='maxresults' value='<?php echo $maxresults ?>' />
<input type='hidden' type='submit' value='submit'>
</form>
<form id='sendpaginationback' action='linkdsearch.php' method='POST' enctype='multipart/form-data' >
<input type='hidden' type='text' name='startfrom2' value='<?php echo $startfrom = $startfrom -5 ?>' />
<input type='hidden' type='text' name='displayto2' value='<?php echo $displayto = 5 ?>' />
<input type='hidden' type='text' name='searchfor' value='<?php echo $search ?>' />
<input type='hidden' type='text' name='price' value='<?php echo $price ?>' />
<input type='hidden' type='text' name='catagory' value='<?php echo $catagory ?>' />
<input type='hidden' type='text' name='location' value='<?php echo $location ?>' />
<input type='hidden' type='text' name='resultcheck' value='<?php echo $resultcheck ?>' />
<input type='hidden' type='text' name='postcode' value='<?php echo $postcode ?>' />
<input type='hidden' type='text' name='maxresults' value='<?php echo $maxresults ?>' />
<input type='hidden' type='submit' value='submit'>
</form>
<img src="pageimages/pictureicon.jpg" ondblclick="changeamountdisplay2();" style='position:absolute; left:20%;'>
<img src="pageimages/vidicon.jpg" ondblclick="changeamountdisplay();" style='position:absolute; left:80%;'>
<p> display<?php echo $displayto; ?> </p>
<p> start from<?php echo $startfrom; ?> </p>
<p> max<?php echo $maxresults; ?> </p>
<p> check<?php echo $resultcheck; ?> </p>
</div>
</div>
<script>
function changeamountdisplay(){
document.getElementById('sendpaginationforward').submit(); return false;
};
</script>
<script>
function changeamountdisplay2(){
document.getElementById('sendpaginationback').submit(); return false;
};
</script>
<script type="text/javascript">
function changeshowdetail(showinglocate,showingphone)
{
document.getElementById(showinglocate).style.opacity=('0.0');
document.getElementById(showinglocate).style.visibility=('hidden');
document.getElementById(showinglocate).style.Zindex=('-1');
document.getElementById(showingphone).style.opacity=('1.1');
document.getElementById(showingphone).style.Zindex=('10');
document.getElementById(showingphone).style.visibility=('visible');
};
function changeshowdetail2(showinglocate,showingphone)
{
document.getElementById(showingphone).style.opacity=('0.0');
document.getElementById(showingphone).style.Zindex=('-1');
document.getElementById(showingphone).style.visibility=('hidden');
document.getElementById(showinglocate).style.opacity=('1.1');
document.getElementById(showinglocate).style.visibility=('visible');
document.getElementById(showinglocate).style.Zindex=('10');
};
</script>
<script>
function controlshowvid(vidd,pidd){
document.getElementById(pidd).style.opacity=('0.0');
document.getElementById(pidd).style.visibility=('hidden');
document.getElementById(vidd).style.opacity=('1.1');
document.getElementById(vidd).style.Zindex=('15');
document.getElementById(pidd).style.Zindex=('-1');
};
function controlshowimage(vidd,pidd){
document.getElementById(vidd).style.opacity=('0.0');
document.getElementById(pidd).style.opacity=('1.1');
document.getElementById(pidd).style.visibility=('visible');
document.getElementById(vidd).style.Zindex=('-1');
document.getElementById(pidd).style.Zindex=('15');
};
</script>
</body>
</html>
事实上,想想看,我最好只是做一个图像滚动而不是分页。我会调查一下。但我确实想知道如何完成分页。但如果有人可以提供简单的图像旋转,我将不胜感激。
最佳答案
经过一番尝试和错误,我最终完成了我打算做的事情。代码最初不起作用的主要原因是因为搜索变量是从最后一个视频/图像/价格/定位/信息/等的最后一个数据库 $data 中更新的。因此变量发送到最后一个图像/视频的表单,而不是搜索字段......我修改了此以删除被发布到表单的变量,并初始化 !isset 和 !empty 以在查询之前设置变量在 POST 之后,变量将被更新为搜索查询数据而不是图像/视频数据。最后,在对代码进行了一些调整之后,我将其启动并运行......
感谢您的关注。我希望这个简单的分页对其他人有帮助 1 天。
这是最终代码..
<?php
//
include ("conect.php");
if (!isset($_POST['direction'])) {
$direction = "1";}
if (!isset($_POST['searchfor'])) {
$search = "";}
if (!isset($_POST['location'])) {
$location = "";}
if (!isset($_POST['postcode'])) {
$postcode = "";}
if (!isset($_POST['price'])) {
$price = "";}
if (!isset($_POST['catagory'])) {
$catagory = "";}
$display=9;
if (empty($maxresults)) {$maxresults=$display; }
if (empty($direction)) {$direction=1; }
if (!empty($direction)) {$direction=$direction; }
if (empty($startfrom)) {$startfrom=0; };
if (empty($displayto)) {$displayto=$display; };
if (empty($resultcheck)) {$resultcheck=0; };
if (!empty($resultcheck)) {$resultcheck=$resultcheck; };
if (!empty($startfrom)) {$startfrom=$startfrom; };
if (!empty($displayto)) {$displayto=$displayto; };
if (!empty($maxresults)) {$maxresults=$maxresults; }
if (isset($_POST['startfrom'])) {
$startfrom = htmlentities($_POST['startfrom'] ); };
if (isset($_POST['displayto'])) {
$displayto = htmlentities($_POST['displayto'] ); };
if (isset($_POST['resultcheck'])) {
$resultcheck = htmlentities($_POST['resultcheck'] ); };
if (isset($_POST['maxresults'])) {
$maxresults = htmlentities($_POST['maxresults'] ); };
if (isset($_POST['searchfor'])) {
$search = htmlentities($_POST['searchfor'] ); }
if (isset($_POST['location'])) {
$location = htmlentities($_POST['location'] ); }
if (isset($_POST['postcode'])) {
$postcode = htmlentities($_POST['postcode'] ); }
if (isset($_POST['price'])) {
$price = htmlentities($_POST['price'] ); }
if (isset($_POST['catagory'])) {
$catagory = htmlentities($_POST['catagory'] ); }
if (isset($_POST['direction'])) {
$direction = htmlentities($_POST['direction'] ); }
//use this for any input to be stored in the database - to eliminate any html or script tags
function ($direction) {
echo htmlspecialchars($search, ENT_QUOTES, 'utf-8');
};
//escape chars - basically escapes such chars as ' or " or # ect ect with a slash//
$direction = mysqli_real_escape_string($conn, $direction);
$direction = filter_var($direction, FILTER_SANITIZE_STRING);
//set error for null value - error to give value a return of 1
if (isset($_POST['searchfor'])) {
$search = htmlentities($_POST['searchfor'] ); }
//use this for any input to be stored in the database - to eliminate any html or script tags
function ($search) {
echo htmlspecialchars($search, ENT_QUOTES, 'utf-8');
};
//escape chars - basically escapes such chars as ' or " or # ect ect with a slash//
$search = mysqli_real_escape_string($conn, $search);
$search = filter_var($search, FILTER_SANITIZE_STRING);
if (empty($search)) { $search="";};
//$search = strtolower($search);
if (isset($_POST['location'])) {
$location = htmlentities($_POST['location'] ); }
//use this for any input to be stored in the database - to eliminate any html or script tags
function ($location) {
echo htmlspecialchars($location, ENT_QUOTES, 'utf-8');
};
//escape chars - basically escapes such chars as ' or " or # ect ect with a slash//
$location = mysqli_real_escape_string($conn, $location);
$location = filter_var($location, FILTER_SANITIZE_STRING);
//$location = strtolower($location);
if (empty($location)) { $location="";};
if (isset($_POST['postcode'])) {
$postcode = htmlentities($_POST['postcode'] ); }
//use this for any input to be stored in the database - to eliminate any html or script tags
function ($postcode) {
echo htmlspecialchars($postcode, ENT_QUOTES, 'utf-8');
};
//escape chars - basically escapes such chars as ' or " or # ect ect with a slash//
$postcode = mysqli_real_escape_string($conn, $postcode);
$postcode = filter_var($postcode, FILTER_SANITIZE_STRING);
//$postcode = strtolower($postcode);
if (empty($postcode)) { $postcode="";};
if (isset($_POST['price'])) {
$price = htmlentities($_POST['price'] ); }
//use this for any input to be stored in the database - to eliminate any html or script tags
function ($price) {
echo htmlspecialchars($price, ENT_QUOTES, 'utf-8');
};
//escape chars - basically escapes such chars as ' or " or # ect ect with a slash//
$price = mysqli_real_escape_string($conn, $price);
$price = filter_var($price, FILTER_SANITIZE_STRING);
//$postcode = strtolower($postcode);
if (empty($price)) { $price="";};
if (isset($_POST['catagory'])) {
$catagory = htmlentities($_POST['catagory'] ); }
//use this for any input to be stored in the database - to eliminate any html or script tags
function ($catagory) {
echo htmlspecialchars($catagory, ENT_QUOTES, 'utf-8');
};
//escape chars - basically escapes such chars as ' or " or # ect ect with a slash//
$catagory = mysqli_real_escape_string($conn, $catagory);
$catagory = filter_var($catagory, FILTER_SANITIZE_STRING);
//$catagory = strtolower($catagory);
if (empty($catagory)) {$catagory="";};
//search according to chosen search critera NOT LIMITED//
if ($resultcheck<1) {
if ($displayto>$maxresults) {$displayto=$maxresults;};
if ($startfrom>$maxresults-$displayto) {$startfrom=$maxresults-$displayto;};
if ($startfrom>$maxresults) {$startfrom=$maxresults-$displayto;};
if ($startfrom<0){$startfrom=0;};
if ($displayto<0) {$displayto=0;};
//echo "D2{$displayto} D{$display} M{$maxresults} S{$startfrom} DIR {$direction}";
if ($direction=1 && $startfrom<0) {$startfrom=0;};
if (empty($postcode)) {
if (!empty($search) && !empty($location)) {
//echo "1. if (!empty($search) && !empty($location)) ";
$sql = "SELECT * FROM testdata
WHERE price LIKE '%%$price%%' AND type LIKE '%%$catagory%%' AND locate LIKE '%%$location%%' AND title LIKE '%%$search%%'
OR price LIKE '%%$price%%' AND locate='$location' AND title LIKE '%%$search%%'
OR price LIKE '%%$price%%' AND locate LIKE '%%$location%%' AND type LIKE '%%$search%%'
OR price LIKE '%%$price%%' AND locate='$location' AND type LIKE '%%$search%%'
";
};
if (empty($search) && !empty($location)) {
$sql = "SELECT * FROM testdata
WHERE price LIKE '%%$price%%' AND type LIKE '%%$catagory%%' AND locate LIKE '%%$location%%' OR locate ='%%$location%%'
";
};
// checks for an empty search value
if (empty($search) && empty($location)) {
$sql = "SELECT * FROM testdata WHERE price LIKE '%%$price%%' AND type LIKE '%%$catagory%%'
";
};
// checks for an empty search value LIMIT 15 1
if (!empty($search) && empty($location)) {
$sql = "SELECT * FROM testdata
WHERE price LIKE '%%$price%%' AND type LIKE '%%$catagory%%' AND title LIKE '%%$search%%' OR info LIKE '%%$search%%'
";
};
};
if (!empty($postcode)) {
if (!empty($search) && !empty($location)) {
//echo "1. if (!empty($search) && !empty($location)) ";
$sql = "SELECT * FROM testdata
WHERE price LIKE '%%$price%%' AND type LIKE '%%$catagory%%' AND locate LIKE '%%$location%%' AND title LIKE '%%$search%%' AND postcode LIKE '%%$postcode%%'
OR price LIKE '%%$price%%' AND locate='$location' AND title LIKE '%%$search%%' AND postcode LIKE '%%$postcode%%'
OR price LIKE '%%$price%%' AND locate LIKE '%%$location%%' AND type LIKE '%%$search%%' AND postcode LIKE '%%$postcode%%'
OR price LIKE '%%$price%%' AND locate='$location' AND type LIKE '%%$search%%' AND postcode LIKE '%%$postcode%%'
";
};
// $sql = "SELECT * FROM $catagory
// WHERE locate LIKE '%%$location%%'ate LIKE '%%$location%%' most recent and working //
if (empty($search) && !empty($location)) {
//echo "2. if (empty($search) && !empty($location))";
$sql = "SELECT * FROM testdata
WHERE price LIKE '%%$price%%' AND type LIKE '%%$catagory%%' AND locate LIKE '%%$location%%' AND postcode LIKE '%%$postcode%%'
OR price LIKE '%%$price%%' AND locate='%%$location%%' AND postcode LIKE '%%$postcode%%'
";
};
// checks for an empty search value
if (empty($search) && empty($location)) {
//echo "3. if (empty($search) && empty($location))";
$sql = "SELECT * FROM testdata
WHERE price LIKE '%%$price%%' AND type LIKE '%%$catagory%%' AND postcode LIKE '%%$postcode%%' OR postcode='%%$postcode%%'
";
};
// checks for an empty search value LIMIT 15 1
if (!empty($search) && empty($location)) {
//echo "4. if (empty($location) && !empty($search))";
$sql = "SELECT * FROM testdata
WHERE price LIKE '%%$price%%' AND type LIKE '%%$catagory%%' AND title LIKE '%%$search%%' AND postcode LIKE '%%$postcode%%'
OR info LIKE '%%$search%%' AND postcode LIKE '%%$postcode%%'
";
};
};
$result = $conn->query($sql);
$row_cnt = $result->num_rows;
if ($resultcheck<1) {$maxresults=$row_cnt;};
$resultcheck="1";
}; //if empty resultcheck
//if $resultcheck not empty
if ($resultcheck=1 OR $resultcheck>1) {
$maxresults=$maxresults;
if ($displayto>$maxresults) {$displayto=$maxresults;};
if ($startfrom>$maxresults-$displayto) {$startfrom=$maxresults-$displayto;};
if ($startfrom>$maxresults) {$startfrom=$maxresults-$displayto;};
if ($startfrom<0){$startfrom=0;};
if ($displayto<0) {$displayto=0;};
if ($direction=1 && $startfrom<0) {$startfrom=0;};
//search results WITH LIMIT $startfrom , $displayto
if (empty($postcode)) {
if (!empty($search) && !empty($location)) {
//echo "1. if (!empty($search) && !empty($location)) ";
$sql = "SELECT * FROM testdata
WHERE price LIKE '%%$price%%' AND type LIKE '%%$catagory%%' AND locate LIKE '%%$location%%' AND title LIKE '%%$search%%'
OR price LIKE '%%$price%%' AND locate='$location' AND title LIKE '%%$search%%'
OR price LIKE '%%$price%%' AND locate LIKE '%%$location%%' AND type LIKE '%%$search%%'
OR price LIKE '%%$price%%' AND locate='$location' AND type LIKE '%%$search%%' LIMIT $startfrom , $displayto
";
};
// $sql = "SELECT * FROM $catagory
// WHERE locate LIKE '%%$location%%' OR locate = '%%$location%%' most recent and working //
if (empty($search) && !empty($location)) {
//echo "2. if (empty($search) && !empty($location))";
$sql = "SELECT * FROM testdata
WHERE price LIKE '%%$price%%' AND type LIKE '%%$catagory%%' AND locate LIKE '%%$location%%' OR locate ='%%$location%%' LIMIT $startfrom , $displayto
";
};
// checks for an empty search value
if (empty($search) && empty($location)) {
//echo "3. if (empty($search) && empty($location))";
$sql = "SELECT * FROM testdata WHERE price LIKE '%%$price%%' AND type LIKE '%%$catagory%%' LIMIT $startfrom , $displayto
";
};
// checks for an empty search value LIMIT 15 , 1
if (!empty($search) && empty($location)) {
//echo "4. if (empty($location) && !empty($search))";
$sql = "SELECT * FROM testdata
WHERE price LIKE '%%$price%%' AND type LIKE '%%$catagory%%' AND title LIKE '%%$search%%' OR info LIKE '%%$search%%' LIMIT $startfrom , $displayto
";
};
};
if (!empty($postcode)) {
if (!empty($search) && !empty($location)) {
//echo "1. if (!empty($search) && !empty($location)) ";
$sql = "SELECT * FROM testdata
WHERE price LIKE '%%$price%%' AND type LIKE '%%$catagory%%' AND locate LIKE '%%$location%%' AND title LIKE '%%$search%%' AND postcode LIKE '%%$postcode%%'
OR price LIKE '%%$price%%' AND locate='$location' AND title LIKE '%%$search%%' AND postcode LIKE '%%$postcode%%'
OR price LIKE '%%$price%%' AND locate LIKE '%%$location%%' AND type LIKE '%%$search%%' AND postcode LIKE '%%$postcode%%'
OR price LIKE '%%$price%%' AND locate='$location' AND type LIKE '%%$search%%' AND postcode LIKE '%%$postcode%%'
LIMIT $startfrom , $displayto
";
};
// $sql = "SELECT * FROM $catagory
// WHERE locate LIKE '%%$location%%'ate LIKE '%%$location%%' most recent and working //
if (empty($search) && !empty($location)) {
//echo "2. if (empty($search) && !empty($location))";
$sql = "SELECT * FROM testdata
WHERE price LIKE '%%$price%%' AND type LIKE '%%$catagory%%' AND locate LIKE '%%$location%%' AND postcode LIKE '%%$postcode%%'
OR price LIKE '%%$price%%' AND locate='%%$location%%' AND postcode LIKE '%%$postcode%%' LIMIT $startfrom , $displayto
";
};
// checks for an empty search value
if (empty($search) && empty($location)) {
//echo "3. if (empty($search) && empty($location))";
$sql = "SELECT * FROM testdata
WHERE price LIKE '%%$price%%' AND type LIKE '%%$catagory%%' AND postcode LIKE '%%$postcode%%'
OR postcode='%%$postcode%%' LIMIT $startfrom , $displayto
";
};
// checks for an empty search value LIMIT 15 , 1
if (!empty($search) && empty($location)) {
//echo "4. if (empty($location) && !empty($search))";
$sql = "SELECT * FROM testdata
WHERE price LIKE '%%$price%%' AND type LIKE '%%$catagory%%' AND title LIKE '%%$search%%' AND postcode LIKE '%%$postcode%%'
OR info LIKE '%%$search%%' AND postcode LIKE '%%$postcode%%' LIMIT $startfrom , $displayto
";
};
};
$result = $conn->query($sql);
$resultcheck=2;
echo" <center><div class='searchresults'> ";
printf("Search Results for {$search} in {$catagory} Within {$location} & Totals %d results {$displayto}&{$startfrom} <br><br>", $maxresults);
echo" </div> </center>";
while($row = mysqli_fetch_assoc($result)) { // while($row = mysqli_fetch_assoc($result)) {
$vid = $row['id']; //<!---important is Video ID and needed for video click selection---->
$type = $row['type'];
$id = $row['id'];
$vidd= $row['id']-0.01;
$pidd= $row['id']-0.02;
$name = $row['Name'];
$image = $row['image'];
$info = $row['info'];
$phone = $row['phone'];
$title = $row['title'];
$locate = $row['locate'];
$postcoded = $row['postcode'];
$price = $row['price'];
$videos = $row['videos'];
$date = $row['stamp'];
$type = $row['type'];
$showinglocate=$row['id']-0.03;
$showingphone=$row['id']-0.04;
echo"
<center>
<div class='floater'>
<div style='position:absolute; top:0%; left:auto; margin:0 auto; display:table; width:100%; height:99%; border-radius: 1vw; box-shadow: 1px 1px 3px 1px #aaa; background-color:white; overflow:hidden;'>
";
if (empty($videos) && empty($image)) {
echo "<img src='image/blank.png' style='position:absolute; top:18%; left:10%; width:80%; height:68%; opacity:0.5; transform: scale(1.0,1.1);'>
"; }
if (!empty($videos)) {
echo "
<video id='$vidd' title='{$row['title']} {$row['locate']}' style='position:absolute; left:0px; top:18%; width:100%; height:60%; transform: scale(1.0,1.1);' preload='metadata' controls='controls'>
<source src='vid/{$row['videos']}.mp4' type='video/mp4'>
<source src='vid/{$row['videos']}.mp4' type='video/ogg'>
<source src='vid/{$row['videos']}.mp4' type='video/webm'>
</video >
<div id='vidicon' title='Video's' class='vidicon' ondblclick='controlshowvid($vidd , $pidd);' ><img src='pageimages/vidicon.jpg' style='position:absolute; top:0%; left:0%; width:100%; height:100%; z-index:1; cursor:hand;'></div>
"; }
if (!empty($image)) {
echo "<img id='$pidd' src='image/{$row['image']}' style='position:absolute; top:18%; left:0%; width:100%; height:60%; transform: scale(1.0,1.1);'>
<div id='pictureicon' title='Pictures' class='pictureicon' ondblclick='controlshowimage($vidd , $pidd);'><img src='pageimages/pictureicon.jpg' style='position:absolute; top:0%; left:0%; width:100%; height:100%; z-index:1; cursor:hand;'></div>
"; }
echo "
<div id='displaytitle' class='displaytitle' ><center>{$row['title']}</center></div></font>
<div id='displaystamp' class='displaystamp' title='{$row['stamp']}'>{$row['stamp']}</div><br></font>
<div id='displaypostcode' class='displaypostcode' title='{$row['postcode']}' >{$row['postcode']}</div><br></font>
<div id='displayprice'><center><strong>£{$row['price']}</strong></center></div>
<div id='$showinglocate' class='showinglocate' style=' 'title='{$row['postcode']}' ondblclick='changeshowdetail($showinglocate, $showingphone)' ><center><strong>{$row['locate']}</strong></center></div>
<div id='$showingphone' class='showingphone' style=' ' title='{$row['Name']}' ondblclick='changeshowdetail2($showinglocate,$showingphone)' ><center><strong>{$row['phone']}</strong></center></div>
<div id='showwhole' class='showwhole' title='View Details Page' ondblclick='' ><img src='pageimages/pageicon.jpg' style='position:absolute; top:0%; left:0%; width:100%; height:100%; z-index:1; cursor:hand;'> <div>
</div>
</div>
</center>
";
}
};
?>
<br>
<div class="footer">
<form id='sendpaginationforward' type='submit' action='linkdsearchpagination.php' method='POST' enctype='multipart/form-data' >
<input type='hidden' type='submit' name='startfrom' value='<?php echo $startfrom+$display?>' />
<input type='hidden' type='submit' name='displayto' value='<?php echo $display ?>' />
<input type='hidden' type='submit' name='resultcheck' value='<?php echo $resultcheck=2 ?>' />
<input type='hidden' type='submit' name='maxresults' value='<?php echo $maxresults ?>' />
<input type='hidden' type='submmit' name='$direction' value='<?php echo 2 ?>' />
<input type='hidden' type='submit' action='submit'>
</form>
<form id='sendpaginationback' type='submit' action='linkdsearchpagination.php' method='POST' enctype='multipart/form-data' >
<input type='hidden' type='submit' name='startfrom' value='<?php echo $startfrom-$display?>' />
<input type='hidden' type='submit' name='displayto' value='<?php echo $display ?>' />
<input type='hidden' type='submit' name='resultcheck' value='<?php echo $resultcheck=2 ?>' />
<input type='hidden' type='submmit' name='maxresults' value='<?php echo $maxresults ?>' />
<input type='hidden' type='submmit' name='$direction' value='<?php echo 1 ?>' />
<input type='hidden' type='submit' action="submit">
</form>
<img src="pageimages/pictureicon.jpg" ondblclick="changeamountdisplay2();" style='position:relative; float:left; bottom:78%; height:80%;margin:10px; z-index:100;'>
<center style="position:relative; top:-30%; left:-3.4%; float:top; "><font style='font-size: 2vw; color:blue;'>Showing Results   <?php echo 1+$startfrom ?>  to <?php echo $startfrom+$displayto ?>   of  <?php echo $maxresults ?></font></center>
<img src="pageimages/vidicon.jpg" ondblclick="changeamountdisplay();" style='position:relative; float:right; bottom:134%; height:80%; margin:10px; z-index:100;'>
</div>
</div>
</div>
</div>
</div>
<script>
function changeamountdisplay(){
document.getElementById('sendpaginationforward').submit(); return false;
};
</script>
<script>
function changeamountdisplay2(){
document.getElementById('sendpaginationback').submit(); return false;
};
</script>
<script type="text/javascript">
function changeshowdetail(showinglocate,showingphone)
{
document.getElementById(showinglocate).style.opacity=('0.0');
document.getElementById(showinglocate).style.visibility=('hidden');
document.getElementById(showinglocate).style.Zindex=('-1');
document.getElementById(showingphone).style.opacity=('1.1');
document.getElementById(showingphone).style.Zindex=('10');
document.getElementById(showingphone).style.visibility=('visible');
};
function changeshowdetail2(showinglocate,showingphone)
{
document.getElementById(showingphone).style.opacity=('0.0');
document.getElementById(showingphone).style.Zindex=('-1');
document.getElementById(showingphone).style.visibility=('hidden');
document.getElementById(showinglocate).style.opacity=('1.1');
document.getElementById(showinglocate).style.visibility=('visible');
document.getElementById(showinglocate).style.Zindex=('10');
};
</script>
<script>
function controlshowvid(vidd,pidd){
document.getElementById(pidd).style.opacity=('0.0');
document.getElementById(pidd).style.visibility=('hidden');
document.getElementById(vidd).style.opacity=('1.1');
document.getElementById(vidd).style.Zindex=('15');
document.getElementById(pidd).style.Zindex=('-1');
};
function controlshowimage(vidd,pidd){
document.getElementById(vidd).style.opacity=('0.0');
document.getElementById(pidd).style.opacity=('1.1');
document.getElementById(pidd).style.visibility=('visible');
document.getElementById(vidd).style.Zindex=('-1');
document.getElementById(pidd).style.Zindex=('15');
};
</script>
</body>
</html>
关于javascript - 点击后分页不显示结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47029583/