Jump to content

Search the Community

Showing results for tags 'search'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

  1. I want to have a search form in one page which has 2 text input fields and a search button. the output should be search results based on below logic: Input1 - category 1 Input2 - category2, common products of category 1 and 2 should be displayed in the search results. I have tried the below code which returns a blank page: Page code: <form action="http://mysite/wp-content/themes/test.php" method="post" name="SearchForm">Cat1 <input id="cat1" name="cat1" type="text" /> Cat2 <input id="cat2" name="cat2" type="text" /> <input type="submit" value="Search" /></form> Test.php contents: <?php $cat1=$_POST["cat1"]; $cat2=$_POST["cat2"]; define('WP_USE_THEMES', false); require_once('../../wp-load.php'); $args = array( 'post_type' => 'product', 'posts_per_page' => 50, 'tax_query' => array( 'relation' => 'AND', array( 'taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => $cat1 ), array( 'taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => $cat2 ) ), ); $loop = new WP_Query( $args ); if ( $loop->have_posts() ) { while ( $loop->have_posts() ) : $loop->the_post(); endwhile; } wp_reset_postdata(); ?> And I am searching with 'cat1' and 'cat2' as inputs in the search form, the slugs for categories are cat1 and cat2 defines in Wordpress. Please help me I am new to PHP. Thanks
  2. I currently have a fulltext search that works. It matches against a item title column in mysql database. Now I would like to include another column to match against. How can that be done properly? Here's my code. Where it says MATCH, I would like to include the type_1 column as well; like this(type_1.type_1_name). $get_records = $db->prepare("SELECT items.*, type_1.* FROM items LEFT JOIN type_1 ON items.type_1 = type_1.type_1_id WHERE MATCH(items.item_title) AGAINST('$search_query' IN BOOLEAN MODE) ORDER BY items.item_id DESC LIMIT {$limit} OFFSET ".$offset); $get_records->execute(); $result_records = $get_records->fetchAll(PDO::FETCH_ASSOC); if(count($result_records) > 0){ foreach($result_records as $row) { // get results } }
  3. hello mate, im having problem making a search criteria work.... i have a field named fullname, inside that field i have a data eg: "Robert Williams" Im trying to use LIKE on mysql statement such as SELECT fullname FROM clients WHERE fullname LIKE '%keyword%' keyword being any character from the name "Robert Williams". but when i tried to search "Williams R" it will not show me "Robert Williams"... Then, how can i make it so that when i search for "Williams R" it will also show me "Robert Williams" What im trying to attain here is to search any name in any order whether firstname first of lastname first. Thank you in advance. Cheers! Neil
  4. For starters, I have only been using PHP for about 2 months now. So, if you feel that there is something I should know, please feel free. I'm all ears. Secondarily, I have been working on this for a couple weeks now and have tried several different angles. I've been to the manual a thousand times, gotten a few bits of advice from Stack Overflow, and looked through YouTube, which is where I found this tutorial: This one. So, I've been through this tutorial a few times. I recreated the search in the video, and now I'm attempting to convert elements of it to my own project. Problem is, it doesn't seem to be parsing things correctly. I will try to explain below. Here is a hastebin with the original code from the video: index page and functions page. And here is my code: search page and functions page. Basically, this code accepts a bunch of values from possible inputs, parses them, and then creates a custom SQL statement. In the original code, the 'locations' are a bunch of checkboxes and one or more can be selected, and the SQL statement is verbose and complex. In my code, the 'categories' are a bunch of checkboxes where one or more can be selected, and the SQL statement is much simpler. That's really why I can't figure out what is going wrong. Here are a few things I have tried so far: 1) I commented out the code and used a generic SQL statement, to make sure the values were being queried and displayed correctly. They were. 2) I've watched the tutorial several times to make sure I have the code correct, and as far as I can tell, I do. 3) I've checked the content of variables, etc., to make sure they are getting sent properly, which they appear to be. 4) Since nothing is coming up as a result of this search currently, I removed some of the NOT symbols (!) from the code, and, lo and behold, everything is now a search result. (In other words, it is either ALL or NOTHING. Not very helpful for a search function.) This is what makes me think things are not getting parsed correctly. I hope this is enough information to get you started. If not, let me now what else I can offer. Thanks for any assistance you can offer!
  5. editor.php: <form action="somesense.php" ... j=new XMLHttpRequest(); j.open("POST","updatenine.php" ... j.open("GET","lb.php? IN RESULT: (editor.php contains) For example, all three files one by one have been being put into array by echoing it with strpos (from that large variable). When searching is under way and strpos comes with it's results ".php" it adds all letters/numbers (until some other leading character). For example for the first strpos finds: "lb.php? .php and adds lb, finishing with lb.php , cutting " and ? from the found line (from code). It cuts " and ? because those symbols aren't proper file names. ----- ----- First found Find pathnames matching a pattern - http://php.net/glob with it's array glob(string pattern [, int flags]) Seems to have some limits, imposed on the forms of representation. I would intend to search within large files. from php's man: "common shells" aren't the best choice for the large-scaled searches. What would you recommend?
  6. help me, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''%jateng%' WHERE (`kabupaten` LIKE '%demak%') OR (`kecamatan` LIKE ' at line 1" <?php $query = $_GET['query']; $select = $_GET['select']; // gets value sent over search form $min_length = 3; // you can set minimum length of the query if you want if(strlen($query) >= $min_length){ // if query length is more or equal minimum length then $query = htmlspecialchars($query); // changes characters used in html to their equivalents, for example: < to > $query = mysql_real_escape_string($query); // makes sure nobody uses SQL injection $raw_results = mysql_query("SELECT * FROM '%".$select."%' WHERE (`kabupaten` LIKE '%".$query."%') OR (`kecamatan` LIKE '%".$query."%')") or die(mysql_error()); // * means that it selects all fields, you can also write: `id`, `title`, `text` // articles is the name of our table // '%$query%' is what we're looking for, % means anything, for example if $query is Hello // it will match "hello", "Hello man", "gogohello", if you want exact match use `title`='$query' // or if you want to match just full word so "gogohello" is out use '% $query %' ...OR ... '$query %' ... OR ... '% $query' if(mysql_num_rows($raw_results) > 0){ // if one or more rows are returned do following while($results = mysql_fetch_array($raw_results)){ // $results = mysql_fetch_array($raw_results) puts data from database into array, while it's valid it does the loop echo "<tr><td>".$results['provinsi']."</td>" ."<td>".$results['kabupaten']."</td>" ."<td>".$results['kecamatan']."</td>" ."<td>".$results['desa']."</td>" ."<td>".$results['kodepos']."</tr>"; // posts results gotten from database(title and text) you can also show id ($results['id']) } } else{ // if there is no matching rows do following echo "No results"; } } else{ // if query length is less than minimum echo "Minimum length is ".$min_length; } ?>
  7. Hi. I have a list of products and each have parts which in turn have their own codes. I need to find the correct part when I have the code. So in the example below, I already have the code '8R195'. I want to check through all the arrays and find which one contains this code, so the output would be A in this case. Any help greatly appreciated $item1 => Array ( ('A') => array('825R15', '825R16', '65R17', '21575R175', '8R195'), ('B') => array('10R225', '825x20', '900R20'), ('C') => array('15R225', '29575R225', '30570R225', '38565R225') )
  8. Hi all, I am working on a search script which searches article titles from the table. i have worked out the function, but have not been able to add an error message if the results are zero. my class file has this following function public function search($table){ $search=$_GET['search']; if ($this->databaseConnection()) { $sql="SELECT * FROM $table WHERE title LIKE '%$search%'"; $q = $this->db_connection->query($sql) or die("failed!"); while($r = $q->fetch(PDO::FETCH_ASSOC)){ $data[]=$r; } return $data; } } my results page has the following code <?php foreach($crud->search("articles") as $value){ extract($value); echo <<<show <p>" <a href="view.php?article_id=$article_id">$title</a> "</p> <br> show; } ?> would be highly obliged if anyone can help me out. apologies if this is a stupid question, but i am pretty much an amateur still. regards, Nayan
  9. I am developing a database application using Yii Framework. I am reading tables from MySQL database and displaying them to the user. I need the user to be able to filter the fields in the table or search for a certain value. For example, I have a table named "supermarkets": CREATE TABLE IF NOT EXISTS `supermarkets` ( `name` varchar(71) NOT NULL, `location` varchar(191) DEFAULT NULL, `telephone` varchar(68) DEFAULT NULL, `fax` varchar(29) DEFAULT NULL, `website` varchar(24) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; .../model/supermarkets: <?php namespace app\models; use yii\db\ActiveRecord; class Supermarkets extends ActiveRecord { } .../views/supermarkets/index.php: <?php use yii\helpers\Html; use yii\widgets\LinkPager; ?> <h1>Supermarkets</h1> <ul> <?php $array = (array) $supermarkets; function build_table($array){ // start table $html = '<table class="altrowstable" id="alternatecolor">'; // header row $html .= '<tr>'; foreach($array[0] as $key=>$value){ $html .= '<th>' . $key . '</th>'; } $html .= '</tr>'; // data rows foreach( $array as $key=>$value){ $html .= '<tr>'; foreach($value as $key2=>$value2){ $html .= '<td>' . $value2 . '</td>'; } $html .= '</tr>'; } // finish table and return it $html .= '</table>'; return $html; } echo build_table($array); ?> ....Controllers/SupermarketsController: <?php namespace app\controllers; use yii\web\Controller; use yii\data\Pagination; use app\models\Supermarkets; class SupermarketsController extends Controller { public function actionIndex() { $query = supermarkets::find(); $pagination = new Pagination([ 'defaultPageSize' => 20, 'totalCount' => $query->count(), ]); $supermarkets = $query->orderBy('Name') ->offset($pagination->offset) ->limit($pagination->limit) ->all(); return $this->render('index', [ 'supermarkets' => $supermarkets, 'pagination' => $pagination, ]); } } I need the user to be able to filter the table or search its fields by one or more attribute. I'm using Yii2, so CDbcriteria doesn't work. How can I do this?
  10. I'm rather new to PHP, and I've run into a problem develeoping this script that I can't figure out. It's fairly simple in that it fetches the user input via a search box and cross references it against a blacklist and whitelist in the form of two seperate .txt. files. However, the enclosed code seems to ignore the second if statement and will always return "unknown website" even if users' input is in the blacklist. The first if statement works correctly though, so I'm a little bit lost as to where I've gone wrong. I'm also not sure how I shoud approach implementing case sensentivity and checking if the user input contains a specfiic word that's on a line. For example, if a user inputted phpfreaks into the search box it would still come out as legimtmate even though I didn't specifically state phpfreaks (it would be the full url, e.g. phpfreaks.com) in the whitelist txt file. From my research I would think the strpos function or preg_match might work, but I'm not sure how I should put it in there. <?php $search = $_POST['search']; $blacklist = file_get_contents("illegitimatesites.txt"); $whitelist = file_get_contents("legitimatesites.txt"); $blacklist = explode("\n", $blacklist); $whitelist = explode("\n", $whitelist); if(in_array($_POST['search'], $whitelist)){ //checks if site is in array echo "This website is an authorised distributor"; } else{ if(in_array($_POST['search'], $blacklist)){ //checks if site is in array echo "This website is NOT an authorised distributor"; } else{ echo "Unknown website"; } } ?>
  11. Hi there, new to the forum Ok so i have a crm and i'm trying to add bits, been pretty succesful at most of it, however i've added a new field "status" and i want to be able to search this field, i've tried copying and changing the existing code, but it doesn't seem to be grabbing it. So here's some exisiting code (that works and searches the field marked "Address" 'address' => array( 'title' => _l('Address:'), 'field' => array( 'type' => 'text', 'name' => 'search[address]', 'value' => isset($search['address'])?$search['address']:'', 'size' => 15, ) ), 'status' => array( 'title' => _l('Status:'), 'field' => array( 'type' => 'text', 'name' => 'search[status]', 'value' => isset($search['status'])?$search['status']:'', 'size' => 15, ) ), I thought a simple name change like above would work, but it doesn't pull anything through, anyone got any ideas?
  12. Hello friends, I am a novice in php. Though I create 2 scripts: 1. students registration form 2. search students by Registration Number Our students' Registration Numbers are as follows: nifeA001, nifeA002 & so on... But when someone enter just "nife" or "n" or "A" etc all the students's data is showing. I want that students can search data by entering only Full Registration Number not a Part. I am placing the search.php code below. Please help me out.... ----------------- Search.php ------------------ <?php mysql_connect("localhost", "root", "") or die("could not connect"); mysql_select_db("student") or die("could not connect"); //collect if(isset($_POST['search'])) { $searchq = $_POST['search']; $searchq = preg_replace("#[^0-9a-z]#i", "", $searchq); //here $query = mysql_query("SELECT * FROM user WHERE registration LIKE '%$searchq%'") or die("could not search!"); $count = mysql_num_rows($query); if($count == 0){ $output = 'There was no search results!'; }else{ while($row = mysql_fetch_array($query)) { $fname = $row['firstname']; $lname = $row['surname']; $id = $row['registration']; $output .= '<div> '.$id.' '.$fname.' '.$lname.'</div>'; } } } ?> <html> <head> </head> <body> <form action="form.php" method="post"> <input type="text" name="search" placeholder="search for students.." <input type="submit" value=">>" /> </form> <?php print("$output");?> </body> </html>
  13. I' stuck with writing function for searching replaced numbers and would really appreciate if someone can tell me what I'm doing wrong. My table structure looks like: CREATE TABLE servis.zamjene_brojeva ( id INT(11) NOT NULL AUTO_INCREMENT, vrijeme TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, pocetni_broj VARCHAR(55) DEFAULT NULL, zamjenski_broj VARCHAR(55) DEFAULT NULL, glavni_broj VARCHAR(55) DEFAULT NULL, postoji_zamjena INT(1) DEFAULT NULL, PRIMARY KEY (id) ) My function looks like this: //funkcija za traženje zamjene brojeva function zamjena_broja($kataloski_broj){ //Traženje zamjenskog broja $upit_zamjena = "SELECT pocetni_broj, zamjenski_broj, glavni_broj FROM zamjene_brojeva WHERE glavni_broj = '$kataloski_broj'"; $rezultat_zamjena = mysql_query($upit_zamjena) or die (mysql_error()); $row = mysql_fetch_array($rezultat_zamjena); $kataloski_broj = $row["zamjenski_broj"]; $broj_zamjena = mysql_num_rows($rezultat_zamjena); return $kataloski_broj; //Traženje druge zamjene broja if ($broj_zamjena <> 0) { $upit_zamjena = "SELECT pocetni_broj, zamjenski_broj, glavni_broj FROM zamjene_brojeva WHERE pocetni_broj = '$kataloski_broj'"; $rezultat_zamjena = mysql_query($upit_zamjena) or die (mysql_error()); $broj_zamjena2 = mysql_num_rows($rezultat_zamjena); $row2 = mysql_fetch_array($rezultat_zamjena); $kataloski_broj = $row2["zamjenski_broj"]; return $kataloski_broj; //Traženje treće zamjene if ($broj_zamjena2 <> 0) { $upit_zamjena = "SELECT pocetni_broj, zamjenski_broj, glavni_broj FROM zamjene_brojeva WHERE pocetni_broj = '$kataloski_broj'"; $rezultat_zamjena = mysql_query($upit_zamjena) or die (mysql_error()); $broj_zamjena3 = mysql_num_rows($rezultat_zamjena); $row3 = mysql_fetch_array($rezultat_zamjena); $kataloski_broj = $row3["zamjenski_broj"]; return $kataloski_broj; } } } In pocetni_broj is old number and in glavni_broj is new number. But it can happen that number in glavni_broj is old and I need to search in pocetni_broj to see if there is even newer number and it can happen 5 or 6 times like that. I need to find all the numbers that are connected, but I'm not getting that. What am I doing wrong?
  14. Hi All, I need to get a small function working for a site I need to build for a group of friends. I was able to get a login page, and a way to add data to the data base. Now I am stuck on the search and show results fuctionalities. I have found tens of scripts on the internet, but most of them are outdated, or I cant get them to work, either it sends me back a blank page, does nothing or sends me to an error page The GOAL User Inputs text in a text box, clicks submit, the data in the text box is looked for in the second collumn of the DB, The information of the collumns 2 to 7 of the DB for the name search are displayed either on the same page or on a new page. Is there any chance you could hel me with that, taken into account that I dont need the html part of the code, I only need help with the php part... Thanks in advance to all the people reading this and the ones helping me...
  15. Hey guys, As my name refers, I am a beginner at school. I had a project in which I had to make a database. The database contains movies which you can search for. However in the beginning, the results only appeared when the name of the movie was fully written. I solved it by using 'LIKE' in the query. But now I got the problem of results being shown before you searched for the results. The form is on the same file as the result. I could seperate them but in this case, it's no option (for some reasons which doesn't matter). Can this problem get solved in an other way? This is the part of the code of my php file: <form id="form1" name="form1" method="post" action="Website2.php"> <div id="Zoekend"> <p> <label for="textfield"></label> <label for="Zoek"></label> <input type="text" name="Zoek" id="Zoek" /> </p> <p> <label> <input type="radio" name="RadioGroup1" value="radio" id="RadioGroup1_0" /> Genre</label> <br /> <label> <input type="radio" name="RadioGroup1" value="radio" id="RadioGroup1_1" /> Naam</label> <br /> <label> <input type="radio" name="RadioGroup1" value="radio" id="RadioGroup1_2" /> Jaar</label> <br /> <label> <input type="radio" name="RadioGroup1" value="radio" id="RadioGroup1_3" /> Regisseur</label> <br /> <input type="submit" name="Zoeken" id="Zoeken" value="Zoeken" /> <br /> </p> </form> </div> <div id="Resultaat"> <h1> Zoekresultaten: </h1> <?php $zoekterm = $_POST['Zoek']; $username = '1509506_dyon'; $wachtwoord = 'u2pv6stvk'; $host = 'fdb6.awardspace.net'; $database = '1509506_dyon'; mysql_connect($host, $username, $wachtwoord); mysql_select_db ($database); $sql = "SELECT * FROM Movies WHERE Genre LIKE '%$zoekterm%'"; $resultaat = mysql_query ($sql); while ( $row = mysql_fetch_assoc($resultaat) ) { echo $row['Genre'] . " - " . $row['Naam'] . " - " . $row ['Jaar'] . " - " . $row ['Regisseur'] .'<br>' ; } $sql = "SELECT * FROM Movies WHERE Naam LIKE '%$zoekterm%'"; $resultaat = mysql_query ($sql); while ( $row = mysql_fetch_assoc($resultaat) ) { echo $row['Genre'] . " - " . $row['Naam'] . " - " . $row ['Jaar'] . " - " . $row ['Regisseur'].'<br>' ; } $sql = "SELECT * FROM Movies WHERE Jaar LIKE '%$zoekterm%'"; $resultaat = mysql_query ($sql); while ( $row = mysql_fetch_assoc($resultaat) ) { echo $row['Genre'] . " - " . $row['Naam'] . " - " . $row ['Jaar'] . " - " . $row ['Regisseur'].'<br>' ; } $sql = "SELECT * FROM Movies WHERE Regisseur LIKE '%$zoekterm%'"; $resultaat = mysql_query ($sql); while ( $row = mysql_fetch_assoc($resultaat) ) { echo $row['Genre'] . " - " . $row['Naam'] . " - " . $row ['Jaar'] . " - " . $row ['Regisseur'] .'<br>'; } ?> </div>
  16. I want to add a search feature to my site so that users can search for videos. Let's say that a user conducts a search and I GET their search query: $squery = isset($_GET['query']) ? $_GET['query'] : ''; Now what should I do? What are the best practices to ensure the security of my database and to provide the most relevant results to the user? Here's what I've got so far. // Make sure a search query was entered. if($squery == '') { echo "<p>You didn't enter a search query.</p>"; } // Strip HTML tags. $squery = strip_tags($squery); // Trim white space. $squery = trim($squery); // Set minimum query length. $min_length = 3; // Make sure query length is more than minimum. if(strlen($squery) < $min_length) { echo "<p>The search query you entered is too short. The minimum number of characters is ".$min_length.".</p>"; } // Connect to MySQL. // Select database. // Escape search query. $squery = mysql_real_escape_string($squery); // Break query into keywords. $keywords = explode(' ', $squery); // Count number of keywords. $no_of_keywords = count($keywords); // If just one keyword, then build statement. if($no_of_keywords == 1) { $sql = "SELECT whatever FROM `video_table` WHERE (col1 LIKE '%.$squery.%' OR col2 LIKE '%.$squery.%')"; } // If multiple keywords, then build statement. else { $sql = "SELECT whatever FROM `video_table` WHERE "; for($i = 0; $i < $no_of_keywords; $i++) { $sql .= "(col1 LIKE '%.$keywords[$i].%' OR col2 LIKE '%.$keywords[$i].%')"; if($i < $no_of_keywords) { $sql .= " OR "; } } } // Run mysql query. $raw_results = mysql_query($sql, $con); // Put results into an array for later use. $results = mysql_fetch_array($raw_results); Can this code's security be improved? How can it be altered to provide more relevant results? Should I omit words such as "to" and "the" from the query? If so, how do I do it? Should I remove punctuation? As always, I appreciate your help. You guys have taught me LOADS!
  17. I present videos on my site. The videos (their titles, descriptions, etc.) are stored in a MySQL database. I want visitors to be able to search my database for videos. My MySQL version is 5.5.40-36.1. The storage engine of my tables is INNODB. The two columns I want searched are: title (varchar; unique index) description (text; no index) According to my research, the best way to allow users to search my database would be to use FULLTEXT, but my INNODB tables are incompatible. FULLTEXT is available for INNODB in MySQL 5.6.4 and above. I would rather not use LIKE '%...%', and I would rather not use a third party solution such as Sphinx because my database will never grow particularly large (I doubt it'll ever exceed 6,000–8,000 videos). What do you guys recommend? Is it okay to use LIKE with a database containing 6,000–8,000 items?
  18. hii.. i want a travel search engine script in php website. i am searching for 2 to 3 days on it. but i dont know how to start. i searched on google. find sme APIs for it. but where to implement those APIs. what code i need to write for it. it would be grateful if anyone give some suggestions on this. thanks and regards.
  19. The issue I am having is that everytime I click the next button, it takes me to the index page. My question is, how do I set up a proper search results link in "href="?page=1" index.php <form action="search" method="GET"> <input type="search" name="search" placeholder="Find products, services ..."> <input type="submit" name="submit" value=""> </form> search.php if(isset($_GET['submit']) && !empty($_GET['search'])) { $value = escape(trim(Input::get('search'))); try { // Find out how many items are in the table $q = DB::getInstance()->query("SELECT * FROM records WHERE MATCH(title) AGAINST('$value' IN BOOLEAN MODE)"); $total = $q->count(); // How many items to list per page $limit = 10; // How many pages will there be $pages = ceil($total / $limit); // What page are we currently on? $page = min($pages, filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT, array( 'options' => array( 'default' => 1, 'min_range' => 1, ), ))); // Calculate the offset for the query $offset = ($page - 1) * $limit; // Some information to display to the user $start = $offset + 1; $end = min(($offset + $limit), $total); // Prepare the paged query $stmt = DB::getInstance()->query("SELECT users.*, records.* FROM records LEFT JOIN users ON records.user_id = users.user_id WHERE MATCH(title) AGAINST('$value' IN BOOLEAN MODE) ORDER BY relevance DESC LIMIT {$limit} OFFSET ".$offset); if($stmt->count()) { // Display the results foreach($stmt->results() as $row) { $date = escape($row->posted); $record_date = escape(Input::facebook_date_format($date)); $record_id = escape($row->record_id); $title = trim($row->title); $slug_title = $row->slug_title; $view_count = escape(intval(number_format($row->views + 1))); $username = escape($row->username); require 'snippets/record_widget.php'; } } else { ?><div class="message"><?php echo 'No records found.';?></div><?php } <?php // The "back" link $prevlink = ($page > 1) ? '<a href="?page=1" title="First page"><img src="images/left-page-arrow-end.png"/></a> <a href="?page=' . ($page - 1) . '" title="Previous page"><img src="images/left-page-arrow-start.png"/></a>' : '<span class="disabled"><img src="images/left-page-arrow-end-disabled.png"/></span> <span class="disabled"><img src="images/left-page-arrow-start-disabled.png"/></span>'; // The "forward" link $nextlink = ($page < $pages) ? '<a href="?page=' . ($page + 1) . '" title="Next page"><img src="images/right-page-arrow-start.png"/></a> <a href="?page=' . $pages . '" title="Last page"><img src="images/right-page-arrow-end.png"/></a>' : '<span class="disabled"><img src="images/right-page-arrow-start-disabled.png"/></span> <span class="disabled"><img src="images/right-page-arrow-end-disabled.png"/></a></span>'; // Display the paging information ?> <div class="pages"> <span class="pages-arrows"><?php echo $prevlink; ?></span> <span class="pages-numbers"><?php echo $page; ?> of <?php echo $pages; ?></span> <span class="pages-arrows"><?php echo $nextlink; ?></span> </div> } catch (Exception $e) { echo '<p>', $e->getMessage(), '</p>'; } } else { Redirect::to('index'); }
  20. Hi guys, What I'm trying to accomplish sounds like fairly easy task but due to my poor knowledge of php this turned to be quite a challenge. What I'm trying to do is to make a php script that will search the keywords on the multiple websites. Websites that I will search are all web shops, selling spare part for home appliances and keywords used are usually original spare part codes. When searching, script is searching these websites using their own search functions and not Google or other search engines. Input for this script should be a CSV file containing list of keywords and URLs of the web shops that needs to be search for all these keywords. Here is the example: http://prntscr.com/4ebhxh Script should perform like this: It picks up the 1st keyword, browse to the URL1, uses its search, searches for the product, if it finds it, copy its price and write it back to original input CSV. If it doesn't find match (search results appear empty) it should write "no match found" and continue to URL2, URL3 and so on... When all URLs from the list are checked for the 1st keyword, scripts picks up 2nd keyword and continues on through all these keywords are not checked. This would be a resulting CSV file after the 1st keyword is checked: http://prntscr.com/4ebj52 After all data from the input CSV file are processed, script should prompt a msg and create a download link for that CSV file to be downloaded. If there are multiple matches, in other words if for one keyword some of the website searches find 2 or more products, something like "More then one match" should be written in the file. Example: http://prntscr.com/4ebkcx Please note that non of the website is using SSL and non of them requires login in order to display the prizes. This fact should make this script easier to build. Its not important for this script to run fast (its better I think to run it with some timeouts because of the server glitches and bottlenecks). What is more important is to make it automatic so one can start it over the night, over the weekends. Number of the URLs would be around 10, and list of keywords from few tens, to a few hundred. If I can provide some additional clarification and info I'm available. Of course I would be willing to pay someone to help me accomplish this task. Cheers Dean
  21. The situation is that I have a large string with some identifiers to say "replace me" with something else. My goal is to replace the values, but if one replacement includes one of the other keys, I don't want to replace it. For example: <?php $str = 'some blob ~abc~ followed by ~def~'; $arr_orig = array( '~abc~', '~def~' ); $arr_new = array( 'value~def~', 'blah' ); echo str_replace( $arr_orig, $arr_new, $str ); ?> This will echo: some blob valueblah followed by blah But that's not what I'm trying to accomplish. Basically, I want ~abc~ to be replaced with the literal: value~def~ and for the ~def~ that happens to be part of that string to NOT be replaced. I hope what I'm asking is clear. Basically, preg_replace/str_replace with arrays seems no different than just doing a FOR loop and replacing ~abc~ and then ~def~. But that's not what I need. I'm hoping that if ~abc~ is replaced with text that happens to be another identifier -- ~def~, ~xyz~, whatever -- that this already replaced text is not again replaced. Is there a built-in function to do something like this? If not, should I just parse the whole string and count characters or something? Seems like a pain (and slow!)
  22. Hello, i need some help/info about searching words in files (txt or xml) and saving them to db or another file. For example ive got an xml file like below: <families> <family> <name>brown</name> <city>denver</city> <members>12</members> </family> <family> <name>jackson</name> <city>new york</city> <members>6</members> </family> </families> i want to search for: <family> then save the lines till it comes to the word </family> and then goes to the next group. did some reading about array, preg_match, strpos functions but dont know where to start. what is the best way to do this? can you guys give me some advise... or links to good tutorials? thanks in advance!
  23. Hi ; I have problem with search script ; This is code ; $search_form = "<form method='get' action='' ><span class='aktif'>Arama</span><input class='aktif' type='text' name='search' ><input class='aktif' type='submit'></form>"; echo $search_form ; $search = isset($_GET['search']) ? trim($_GET['search']): ''; $a1=(str_replace(' ', '',$search) ); $S1 = ' '; $S2 = ' '; $S3 = ' '; if($search != ''){ // Terimlerin Arama Kısmı $S1 = sprintf("WHERE Tetik_Ref like '%%%s%%' OR ",mysql_real_escape_string($search)); $S2 = sprintf("Marka_Model like '%%%s%%' OR",mysql_real_escape_string($search)); $S3 = sprintf("Orj_P_N like '%%%s%%'",mysql_real_escape_string($search)); } //Verilerin yazdırılma işlemi $main_query = "SELECT * FROM ats_motor $S1 $S2 $S3 "; $count_query = "SELECT COUNT(*) FROM ats_motor $S1 $S2 $S3 "; Orj_P_N column inside Original Part Numbers. Its same of "111 11 111" or "15K 1245 45" etc. When i search exact records work fine. But I search 11111111 nothing found. I search that and find str_replace function. But i cant use that. Cant import. I try change line 8 and 14. it give me error. Can anybody help me ? Thanks.
  24. I am working on a site for someone and altered the quick search widget (that came with the plugin) in the footer. It searches by country, which then populates states, which when chosen populates city choices. The only page it will function correctly is on the members page of the plugin. Will not work on any other page. Can someone please take a look at my code and see where I went wrong? wp_search_wiget_form.php
  25. Right now I am using a session to get search's input terms and place them into meta tags(title). It works; the only issue is that the search terms lag 1 page behind. For eg. If i search "flowers" on first try, it will show flowers in the metas(title). Next I input "treehouse" in search; instead of "treehouse" showing in the metas, it'll still show me the previous term "flowers". Now if I do a third search with a new term, it won't show the new term in metas, it'll show me the previous term "treehouse". Why is this happening? Am I doing something wrong? This is only an issue with meta tags. Search itself works fine. It shows results on a page as it's suppose to.
  • 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.