mahenda
Members-
Posts
146 -
Joined
-
Last visited
Everything posted by mahenda
-
<?php if(isset($_GET['submit']) && isset($_GET['submit']) !=""){ include_once('conn.php'); $movieName = $_GET['search']; $escapeString = mysqli_real_escape_string($conn, $movieName ); $resultPerPage = 8; if (isset($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; } $startPage = ($page-1) * $resultPerPage; $sql = "SELECT *FROM movies WHERE name LIKE %$escapeString% OR producer LIKE %$escapeString% "; $result = mysqli_query($conn, $sql); while($rows = mysqli_fetch_all($result, MYSQLI_ASSOC)){ echo ' <div> <span>'.$rows['name'].'</span> <span>'.$rows['producer'].'</span> <p>'.$rows['shortDescription'].'</p> </div> '; }} ?> <?php $cSql = "SELECT COUNT(moviesId) FROM movies"; $cResult = mysqli_query($conn, $cSql); $row = mysqli_fetch_row($cResult); $totalRecords = $row[0]; $totatPages = ceil($totalRecords/ $resultPerPage); $pageLink = "<ul class='pagination'>"; for ($i=1; $i<=$totalPages; $i++) { $pageLink .= "<li><a href='search.php?page=".$i."'>".$i."</a></li>"; }; echo $pageLink . "</ul>"; ?> why this code give me all record in database when i search for some movies and the page link on pagination is not disabled when there is two or one record and when i clicked on it, it give me blank page just help me with an example i want the search result appear with pagination like when someone searching on google
-
<?php if(isset($_POST['submit']) && isset($_POST['submit']) !=""){ include_once('conn.php'); $movieName = $_POST['search']; $sql = "SELECT *FROM movies WHERE name LIKE %$movieName% OR producer LIKE %$movieName% "; $result = mysqli_query($conn, $sql); while($rows = mysqli_fetch_all($result, MYSQLI_ASSOC)){ echo ' <div> <span>'.$rows['name'].'</span> <span>'.$rows['producer'].'</span> <p>'.$rows['shortDescription'].'</p> </div> '; }} ?> undefined index error occur and mysqli_fetch_all() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\tmovies\func\searh.php on line 7
-
for example i have index.php as my home page it is already having some information (blog like structure) <!DOCTYPE html> <html> <head> <title>Home</title> </head> <body> <!--navigation here--> <!--search here--> <form action="search.php" method="GET"> <input type="text" placeholder="Enter movie name" name="search"> <button type="submit" value="search" title="search"></button> </form> <!--default content here--> </body> </html> on the above code i want to implement search from mysql database so when user search and submit the default content disappear and new search page with search result appear if there is more than 5 result it will create pagenation this is table mysql table CREATE TABLE movies ( Id INT(11) NOT NULL UNIQUE AUTO_INCREMENT, cover VARCHAR(255) NOT NULL, name CHAR(25) NOT NULL, genre CHAR(25) NOT NULL, producer CHAR(25) NOT NULL, shortDescription CHAR(25) NULL, PRIMARY KEY (Id) ); what about php code <?php include_once ('conn.php'); $sql = "SELECT *FROM movies"; $result = mysqli_query($conn, $sql); while($row = mysqli_fetch_array($result)){ echo ' <div> <span>'.$row['name'].'</span> <span>'.$row['producer'].'</span> <p>'.$row['shortDescription'].'</p> </div> '; } ?>
-
it helped me but when i resize screen it show only first item and white space on the right side ,also when i click the next button there is onlly one item shown wit white space as i said what is the problem look here <div class="nyie-outer"> <div class="container"> <div id="nyieFull" class="carousel slide carousel-multi-item" data-interval="false" data-ride="carousel"> <div class="outer-controls-top"> <div class="nyie-title"><h5>THIS IS NYIE</h5></div> <div class="controls-top"> <a class="btn-floating" href="#nyieFull" data-slide="prev"><i class="fa fa-chevron-left"></i></a> <a class="btn-floating" href="#nyieFull" data-slide="next"><i class="fa fa-chevron-right"></i></a> </div> </div> <div class="carousel-inner newAdded" role= "listbox"> <div class="carousel-item active"> <div class="col-lg-3">... </div> //only this is shown with white space at right side <div class="col-lg-3">... </div>//not shown <div class="col-lg-3">... </div>//not shown <div class="col-lg-3">... </div>//not shown </div <div class="carousel-item "> <div class="col-lg-3">... </div> //only this is shown with white space at right side <div class="col-lg-3">... </div>//not shown <div class="col-lg-3">... </div>//not shown <div class="col-lg-3">... </div>//not shown </div </div> </div> </div> what i want to be here is <div class="carousel-item active"> <div class="col-lg-3">... </div> //show this by default <div class="col-lg-3">... </div>//show this after next button clicked <div class="col-lg-3">... </div>//show this after next button clicked <div class="col-lg-3">... </div>//show this after next button clicked </div <div class="carousel-item "> <div class="col-lg-3">... </div> //show this by default <div class="col-lg-3">... </div>//show this after next button clicked <div class="col-lg-3">... </div>//show this after next button clicked <div class="col-lg-3">... </div>//show this after next button clicked </div
-
<?php include_once('db.php'); $sql = "SELECT image,prodName, prodPrice, description FROM product ORDER BY prodId DESC LIMIT 8"; $prodres = mysqli_query($conn, $sql); $newprod = mysqli_fetch_all($prodres, MYSQLI_ASSOC); $fourDiv = array_chunk($newprod, 4); ?> <div class="nyie-outer"> <div class="container"> <div id="nyieFull" class="carousel slide carousel-multi-item" data-interval="false" data-ride="carousel"> <div class="outer-controls-top"> <div class="nyie-title"><h5>THIS IS NYIE</h5></div> <div class="controls-top"> <a class="btn-floating" href="#nyieFull" data-slide="prev"><i class="fa fa-chevron-left"></i></a> <a class="btn-floating" href="#nyieFull" data-slide="next"><i class="fa fa-chevron-right"></i></a> </div> </div> <div class="carousel-inner" role="listbox"> <?php foreach ($fourDiv as $products ) { echo '<div class="carousel-item items">'; foreach ($products as $p) { echo ' <div class="col-lg-3"> <a href=""> figure class="figure"> <img src="images/'. $p['image'] .'" alt="" class="img-responsive" > <figcaption class="figure-caption"> <span class="prodName"><b>Name: </b>'. $p['prodName'] .'</span> <span class="prodPrice"><b>price: </b>'. $p['prodPrice'] .'</span> <span class="desc"><b>description: </b>'. $p['description'] .'</span> </figcaption> </figure> </a> </div> '; } echo '</div>'; } ?> </div </div> </div> </div>
-
i have 8 division (div), i want to display 4 rows in 4 division and the remain 4 rows in the next 4 division here is my code structure for carousel <div class="nyie-outer"> <div class="container"> <div id="nyieFull" class="carousel slide carousel-multi-item" data-interval="false" data-ride="carousel"> <div class="outer-controls-top"> <div class="nyie-title"><h5>THIS IS NYIE</h5></div> <div class="controls-top"> <a class="btn-floating" href="#nyieFull" data-slide="prev"><i class="fa fa-chevron-left"></i></a> <a class="btn-floating" href="#nyieFull" data-slide="next"><i class="fa fa-chevron-right"></i></a> </div> </div> <div class="carousel-inner" role="listbox"> <div class="carousel-item active"> first row second row third row fourth row </div><!--/.First four rows here--> <div class="carousel-item"> fifth row sixth row seven throw eighth row </div><!--/.second four rows here--> </div </div> </div> </div> sql code CREATE TABLE product( prodId INT(11) NOT NULL UNIQUE AUTO_INCREMENT, image VARCHAR(255) NOT NULL, prodName VARCHAR(255) NOT NULL, prodPrice VARCHAR(255) NOT NULL, description TEXT NOT NULL PRIMARY KEY (prodId) ); php code <?php include_once('db.php'); $sql = "SELECT image,prodName, prodPrice, description FROM product ORDER BY prodId ASC LIMIT 4"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { // output data of each row while($row = mysqli_fetch_array($result)) { $activeprod = ' <div class="col-lg-3"> <a href="more.php" class="newAdded"> <figure class="figure"> <img src="images/'. $row['image'] .'" alt="" class="img-responsive" > <figcaption class="figure-caption"> <span class="prodName"><b>Name: </b>'. $row['prodName'] .'</span> <span class="prodPrice"><b>price: </b>'. $row['prodPrice'] .'</span> <span class="desc"><b>description: </b>'. $row['description'] .'</span> </figcaption> </figure> </a> </div> '; } } ?> how can i echo that result in those rows