Jump to content

mahenda

Members
  • Content Count

    97
  • Joined

  • Last visited

Everything posted by mahenda

  1. <?php //I added name="submit" in the form now my cde are //let's start with this part before pagination is this correct and secured ?! help me with example if(isset($_GET['submit'])){ include_once('conn.php'); $movieName = $_GET['search']; $escapeString = mysqli_real_escape_string($conn, $movieName ); if($escapeString !=""){ $sql = "SELECT name, producer FROM movies WHERE name LIKE '%".$escapeString."%' OR producer LIKE '%".$escapeString."%' "; $result = mysqli_query($conn, $sql); if($rows = mysqli_fetch_all($result)){ echo ' <div> <span>'.$rows['name'].'</span> <span>'.$rows['producer'].'</span> </div> '; } else { echo "<span> no such term in our database! </span>"; } else { echo "<span> you have to enter search term in the field! </span>"; } ?> look at that guys
  2. <?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
  3. thanks i got it but how can i make good search functionality and prevent from any injectiction i.e sql and script injection .
  4. <?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
  5. 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> '; } ?>
  6. 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
  7. it helped me but when i resize screen it show only one item and white space on the right side but also when i click the button for next slide there is another one item only wit white space shown what is the problem test the code above
  8. I'm sorry guys I experienced another problem on the code above it display well at large device but when at small devices such as phone and tablets only two product shown and leave space on the right It means the figure doesn't fitting the col-lg-3 Help me please @Borand @cyberRobot
  9. <?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>
  10. thanks a lot it was my fault on calling $chunk in foreach loop it helped me but how to put the next four item hidden as my carousel on non active item
  11. Can you tryagain to show me in myaql maybe i'll understand I'm not an experienced developer
  12. i'm using mysqli procedural and getting an error t at fetchal() when i'm using mysqli_fetch_all($result,MYSQL_ASSOC); with chuck variable in say undefined variable $product $products = mysqli_fetch_All(); $chunks = array_chunk($products, 4);
  13. 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
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.