Jump to content

mahenda

Members
  • Content Count

    25
  • Joined

  • Last visited

Community Reputation

0 Neutral

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. i tried to follow some instruction here but i don't achieve ,i'm getting into trouble I know you helped me on this it will be better , if someone can show me an example with source code according to mac_gyver @mac_gyver @Barand @cyberRobot and others pleaseeeeeeeeeee! i cant handle it without some snippet help help me guys
  2. //according to mac_gyver i'm trying step 1 here help for any mistakes <?php if(isset($_GET['submit'])){ include_once('conn.php'); $names = $_GET['search']; $escapeString = mysqli_real_escape_string($conn, $names); if($escapeString !=""){ $sql = "SELECT name,poducer FROM movies WHERE name LIKE '%.$escapeString.%' OR producer LIKE '%.$escapeString.%' "; $result = mysqli_query($conn, $sql); if(mysqli_num_rows($result) >0){ echo ' <div class="head"> <h6 class="ml-0"> RESULT RELATED WITH: <span class="text-success">'.$escapeString.'</span></h6> </div>'; while($row = mysqli_fetch_assoc($result)){ echo '<div> <span>'.$row['name'].'</span> <span>'.$row['producer'].'</span> </div> '; } } else{ echo ' <div class="head"> <h6 class="ml-0"> RESULTS REPORT:</h6> </div>'; echo '<span>The term </span><span class="text-warning"> '.$escapeString.' </span><span> is not available in our database </span><br><span> try <a href="#" style="text-decoration:none;">Advanced Search</a> </span>'; } } else{ echo '<span>you have to enter something</span>'; } } ?> //updated
  3. //according to mac_gyver i'm trying step 1 here help for any mistakes <?php if(isset($_GET['submit'])){ include_once('conn.php'); $names = $_GET['search']; $escapeString = mysqli_real_escape_string($conn, $names); if($escapeString !=""){ $sql = "SELECT name,poducer FROM movies WHERE name LIKE '%.$escapeString.%' OR producer LIKE '%.$escapeString.%' "; $result = mysqli_query($conn, $sql); if(mysqli_num_rows($result) >0){ echo ' <div class="head"> <h6 class="ml-0"> RESULT RELATED WITH: <span class="text-success">'.$escapeString.'</span></h6> </div>'; while($row = mysqli_fetch_assoc($result)){ echo '<div> <span>'.$row['name'].'</span> <span>'.$row['producer'].'</span> </div> '; } } else { echo ' <div class="head"> <h6 class="ml-0"> RESULTS REPORT:</h6> </div>'; echo '<span>The term </span><span class="text-warning"> '.$escapeString.' </span><span> is not available in our database </span><br><span> try <a href="#" style="text-decoration:none;">Advanced Search</a> </span>'; } else{ echo '<span> Mh! You have to Enter search term'; } } } ?>
  4. //i want to put all result into pagination help me how to structure the php code check the first search php code an the second pagination codes //search php code 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($row = mysqli_fetch_assoc($result)){ echo ' <div> <span>'.$row['name'].'</span> <span>'.$row['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>"; } ?> //pagination php code $limit = 8; if (isset($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; } $startPage= ($page-1) * $limit; $sql = "SELECT COUNT(moviesId) FROM movies"; $result = mysqli_query($conn, $sql); $row = mysqli_fetch_row($result); $totalRecords = $row[0]; $totalPages = ceil($totalRecords / $limit); $pageLink = "<ul class='pagination'>"; for ($i=1; $i<=$totalPages; $i++) { $pageLink .= "<li><a href='search.php?page=".$i."'>".$i."</a></li>"; } echo $pageLink . "</ul></nav>";
  5. so i have to use mysqli_fetch_assoc and how t can i highlight the search text using tis codes please i need example i'm not an an experienced developer
  6. <?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
  7. <?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
  8. thanks i got it but how can i make good search functionality and prevent from any injectiction i.e sql and script injection .
  9. <?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
  10. 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> '; } ?>
  11. 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
  12. 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
×

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.