Jump to content

Search the Community

Showing results for tags 'search'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • 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

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. I found the issue: $letters = ereg_replace("[^A-Za-z0-9 ]", "", $searched); Thanks everyone.
  2. I have a fulltext search setup. The issue I have is that I have to add it on every page and do an if statement. The search box is shown fixed position at the top of the website. I was wondering if there is a way I can set it up so that no matter what page I am on, it'll do the search without modifying the selected page? For eg. <html> <head> <title>home page</title> </head> <body> <?php if(isset($_GET['search'])) { echo 'search.php'; } else { // echo rest of the page content. } ?> </body> </html>
  3. Hi, I am trying to make an autocomplete search bar - so for example if want to search for "Sony D3256 Camera" and I type "Sony camera" in the search bar, it still suggest the "Sony D3256 Camera". The ones that I found on blogs and forums are the ones that shows the suggestion until you break the sequence of the name. I am using PHP and MySQL Is this possible, or cannot be done?
  4. I got a movie search website but when I search something it says 404 page not found. The site is working under a framework called code igniter. Here is the back-end code of search engine: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Search extends CI_Controller { function __construct() { parent::__construct(); } public function index($extra=array()) { $q = $this->input->get('q'); if (!empty($q)) { redirect('search/' . $q); } redirect(); } public function do_search() { $this->load->model('movies'); $this->load->model('ssearch'); $search_string = $this->uri->segment(2); $data['main_menubar']['categories'] = $this->movies->get_all_categories(); $data['search']['results'] = $this->ssearch->search_for_movies($search_string); echo $this->load->view('includes/header', (isset($data['header']) ? $data['header'] : ''), true); echo $this->load->view('includes/main_menubar', (isset($data['main_menubar']) ? $data['main_menubar'] : ''), true); echo $this->load->view('search', (isset($data['search']) ? $data['search'] : ''), true); echo $this->load->view('includes/footer', (isset($data['footer']) ? $data['footer'] : ''), true); } } And the front-end code: <div class="content_segment recentMovies clearfix"> <div class="segment_title clearfix"> Search: <?php echo urldecode($this->uri->segment(2)); ?> </div> <!-- segment_title --> <div class="inner_padding clearfix"> <div class="horisontal_movie_list clearfix"> <?php if(empty($results)) : ?> <p>No movies found.</p> <?php endif; ?> <ul> <?php if(!empty($results)): ?> <?php foreach($results as $movie) : ?> <?php $categories = explode(',', $movie['categories']); $cat_ids = explode(',', $movie['categories_id']); $movie['categories'] = ""; for ($i=0; $i < count($categories); ++$i) { $movie['categories'] .= '<a href="'.site_url('view/category/'. $cat_ids[$i]).'">'.$categories[$i].'</a>, '; } $movie['categories'] = substr($movie['categories'], 0, -2); ?> <li> <a href="<?php echo site_url('view/movie/'. $movie['id']); ?>"> <div class="imageWrapper"> <img src="<?php echo base_url() . 'img/movie_covers/' . $movie['cover_image']; ?>" alt="No cover!" /> </div> </a> <div class="information"> <h4 class="title"> <?php if($movie['favorite'] == 1) : ?><img src="<?php echo base_url(); ?>img/other/favorite_icon_small.png" alt="" /><?php endif; ?> <a href="<?php echo site_url('view/movie/'. $movie['id']); ?>"> <?php echo $movie['movie_title']; ?> </a> </h4> <p class="meta"><?php echo $movie['categories']; ?> | <?php echo $movie['release_date']; ?> | First watched <?php echo date('F j, Y', $movie['watch_date']); ?></p> <p class="description"><?php echo $movie['description']; ?></p> </div> </li> <?php endforeach; ?> <?php endif; ?> </ul> </div> </div> <!-- list --> </div> <!-- content_segment --> The menu bar search: <menu class="menubar clearfix"> <a class="logo" href="<?php echo site_url(); ?>"></a> <ul class="clearfix"> <li> <a href="<?php echo site_url() ?>"> Home </a> </li> <li> <a href="<?php echo site_url('view/movies'); ?>"> Movies </a> </li> <li class="categories_link"> <a href="<?php echo site_url('view/category') ?>"> Categories </a> <ul> <?php foreach ($categories as $cat) : ?> <li><a href="<?php echo site_url('view/category/' . $cat['id']); ?>"><?php echo $cat['name']; ?></a></li> <?php endforeach; ?> </ul> </li> <li> <a href="<?php echo site_url('admin') ?>"> Admin area </a> </li> </ul> <div class="search"> <form action="<?php echo site_url('search'); ?>" method="GET"> <input type="search" name="search.php" value="" autofocus placeholder="Search" /> </form> </div> </menu> I hope someone finds a solution, I am stuck for 2 days. Cheers.
  5. I have a setup where I can do single word search and it returns the data. However, I am looking to add a multi word functionality. So far no luck. Anyone here know how to do it and point me in the right direction?
  6. Ok if have some code that i am trying to add to. <form action="#" method="post" enctype="multipart/form-data"> <input type="text" name="search"/> <input type="submit" name="search1"/> </form> <?php if(isset($_POST['search1'])){ $search=mysql_real_escape_string($_POST['search']); } include 'connect.php'; if(isset($_POST['search1'])){ $query=mysql_query("SELECT * FROM media WHERE extra_cred LIKE '%".$search."%' OR artist_id LIKE '%".$search."%' OR title LIKE '%".$search."%' OR content LIKE '%".$search."%' OR detail LIKE '%".$search."%' OR tags LIKE '%".$search."%' OR user LIKE '%".$search."%' OR type LIKE '%".$search."%' ") ?> What I would like to do is also search another table within that database by the name of artists with the same POST data. Anyone know what to do? I've been at this for a while.
  7. I need to output in product-list.tpl file the result of a query from within classes/Search.php in Prestashop. The query in classes/Search.php is: $sql = 'SELECT * FROM `'._DB_PREFIX_.'category_group` cg INNER JOIN `'._DB_PREFIX_.'category_product` cp ON cp.`id_category` = cg.`id_category` INNER JOIN `'._DB_PREFIX_.'category` c ON cp.`id_category` = c.`id_category` INNER JOIN `'._DB_PREFIX_.'product` p ON cp.`id_product` = p.`id_product` INNER JOIN `'._DB_PREFIX_.'product_part_number` ON p. `id_product` = `ID` '.Shop::addSqlAssociation('product', 'p', false).' WHERE c.`active` = 1 AND product_shop.`active` = 1 AND product_shop.`visibility` IN ("both", "search") AND product_shop.indexed = 1 AND cg.`id_group` '.(!$id_customer ? '= 1' : 'IN ( SELECT id_group FROM '._DB_PREFIX_.'customer_group WHERE id_customer = '.(int)$id_customer.' )'); $results = $db->executeS($sql); This is outputting a series of "GREKA" values in the `'._DB_PREFIX_.'product_part_number` table at the top of the search results page from the query above: $eligible_products = array(); foreach ($results as $row){ $eligible_products[] = $row['id_product']; echo $row['GREKA']; } What I need it to do is output the "GREKA" value within the tpl file themes/product-list.tpl for that product. This tpl file is using Smarty to output the results of the product search, I need to know how to call the "GREKA" value from the query to the foreach loop. I imagine it would be something like this: {foreach from=$products item=product name=products} {$GREKA} {/foreach} I have tried to put this line of code inside the foreach on the product-list.tpl and it gives me no output , it gives me an error: Code: {$product.GREKA} Error: Notice: Undefined index: GREKA
  8. Hello, I have 100 of html pages locally stored in a spefic format. I am trying to extract a line from that html pages using php. I can able to search the string and i can able to determine whether the search string is found or not. so far i achieved is <?php $url = 'mylocalpage.html'; $searchstring= 'itemtype'; $contents = file_get_contents($url); if(strpos($contents, $searchstring)!== false) { echo 'Item found'; } else { echo 'Item not found'; } ?> _____________________ Example mylocalpage.html <html> <body> <script> var itemtype = "Mobile"; </script> . . . ..... </body> </html> The next step i need is if it is found i need to copy the entire line from that page. That is if itemtype found I need to copy the entire line that is (var itemtype = "Mobile";) any help appreciated !
  9. Hi, I'm after a song search request script to be made for my website below is some info and bullet points of what I would like the script to have. > Search box and the php script will read a .csv file and show matching data > Search results to show up in table column 1 radio button, column 2 Artists, column 3 tracks, > Above results search box below search results a contact form that will email song request and Name (mandatory), email (mandatory) Dedicate (optional) comment (optional) to my own email address > Alphabetical listing (ie clicking A will show all artists beginning with A) Above search box I do have some other ideas - email me and I'll give you my Skype ID so we can talk more
  10. I have a search class with pagination and I can get the first page to display correctly but the next page gives a bunch of undefined index(s). I know i need to pass the variables to the next page but it only uses one "View" and a "Class". I have tried to make all the $_POST variables into $_SESSIONS and that still did not work. Im sure if I could make the pagination stay at "Search" and not go to "Search?page=2" it might work, but I don't know how to do that exactly. Here is the Pagination and Search Function class/code: <?php class Search extends MainController{ function __construct(){ parent::__construct(); $this->view->url = $this->config->url; $this->view->ID = get_class($this); $this->view->Title = "Diablo 3 Online Auction House"; $this->view->msg = ""; $this->view->err = false; $itemName = isset($_POST['item_name']) ? $_POST['item_name'] : ''; $val_1 = $_POST['attrib1']; $val_2 = $_POST['attrib2']; $val_3 = $_POST['attrib3']; $val_4 = $_POST['attrib4']; $val_5 = $_POST['attrib5']; $val_6 = $_POST['attrib6']; $val_7 = $_POST['attrib7']; $val_8 = $_POST['attrib8']; $itemAttrib1 = $_POST['list_1']; $itemAttrib2 = $_POST['list_2']; $itemAttrib3 = $_POST['list_3']; $itemAttrib4 = $_POST['list_4']; $itemAttrib5 = $_POST['list_5']; $itemAttrib6 = $_POST['list_6']; $itemAttrib7 = $_POST['list_7']; $itemAttrib8 = $_POST['list_8']; $Quality = $_POST['quality']; $Type = $_POST['type']; $sub_Type = $_POST['sub']; $page = (isset($_GET['page'])) ? (int)$_GET['page'] : 1; // If the page wasn't set, lets set $page to number 1 for the first page $sql = "SELECT * FROM items_us_sc WHERE item_name = :item_name AND quality = :quality AND type = :type AND sub_type = :sub AND ((attrib_1 = :prop1 AND value_1 >= :val1 OR attrib_2 = :prop1 AND value_2 >= :val1 OR attrib_3 = :prop1 AND value_3 >= :val1 OR attrib_4 = :prop1 AND value_4 >= :val1 OR attrib_5 = :prop1 AND value_5 >= :val1 OR attrib_6 = :prop1 AND value_6 >= :val1 OR attrib_7 = :prop1 AND value_7 >= :val1 OR attrib_8 = :prop1 AND value_8 >= :val1) AND (attrib_1 = :prop2 AND value_1 >= :val2 OR attrib_2 = :prop2 AND value_2 >= :val2 OR attrib_3 = :prop2 AND value_3 >= :val2 OR attrib_4 = :prop2 AND value_4 >= :val2 OR attrib_5 = :prop2 AND value_5 >= :val2 OR attrib_6 = :prop2 AND value_6 >= :val2 OR attrib_7 = :prop2 AND value_7 >= :val2 OR attrib_8 = :prop2 AND value_8 >= :val2) AND (attrib_1 = :prop3 AND value_1 >= :val3 OR attrib_2 = :prop3 AND value_2 >= :val3 OR attrib_3 = :prop3 AND value_3 >= :val3 OR attrib_4 = :prop3 AND value_4 >= :val3 OR attrib_5 = :prop3 AND value_5 >= :val3 OR attrib_6 = :prop3 AND value_6 >= :val3 OR attrib_7 = :prop3 AND value_7 >= :val3 OR attrib_8 = :prop3 AND value_8 >= :val3) AND (attrib_1 = :prop4 AND value_1 >= :val4 OR attrib_2 = :prop4 AND value_2 >= :val4 OR attrib_3 = :prop4 AND value_3 >= :val4 OR attrib_4 = :prop4 AND value_4 >= :val4 OR attrib_5 = :prop4 AND value_5 >= :val4 OR attrib_6 = :prop4 AND value_6 >= :val4 OR attrib_7 = :prop4 AND value_7 >= :val4 OR attrib_8 = :prop4 AND value_8 >= :val4) AND (attrib_1 = :prop5 AND value_1 >= :val5 OR attrib_2 = :prop5 AND value_2 >= :val5 OR attrib_3 = :prop5 AND value_3 >= :val5 OR attrib_4 = :prop5 AND value_4 >= :val5 OR attrib_5 = :prop5 AND value_5 >= :val5 OR attrib_6 = :prop5 AND value_6 >= :val5 OR attrib_7 = :prop5 AND value_7 >= :val5 OR attrib_8 = :prop5 AND value_8 >= :val5) AND (attrib_1 = :prop6 AND value_1 >= :val6 OR attrib_2 = :prop6 AND value_2 >= :val6 OR attrib_3 = :prop6 AND value_3 >= :val6 OR attrib_4 = :prop6 AND value_4 >= :val6 OR attrib_5 = :prop6 AND value_5 >= :val6 OR attrib_6 = :prop6 AND value_6 >= :val6 OR attrib_7 = :prop6 AND value_7 >= :val6 OR attrib_8 = :prop6 AND value_8 >= :val6) AND (attrib_1 = :prop7 AND value_1 >= :val7 OR attrib_2 = :prop7 AND value_2 >= :val7 OR attrib_3 = :prop7 AND value_3 >= :val7 OR attrib_4 = :prop7 AND value_4 >= :val7 OR attrib_5 = :prop7 AND value_5 >= :val7 OR attrib_6 = :prop7 AND value_6 >= :val7 OR attrib_7 = :prop7 AND value_7 >= :val7 OR attrib_8 = :prop7 AND value_8 >= :val7) AND (attrib_1 = :prop8 AND value_1 >= :val8 OR attrib_2 = :prop8 AND value_2 >= :val8 OR attrib_3 = :prop8 AND value_3 >= :val8 OR attrib_4 = :prop8 AND value_4 >= :val8 OR attrib_5 = :prop8 AND value_5 >= :val8 OR attrib_6 = :prop8 AND value_6 >= :val8 OR attrib_7 = :prop8 AND value_7 >= :val8 OR attrib_8 = :prop8 AND value_8 >= :val8))"; $arr = array(":item_name" => $itemName, ":quality" => $Quality, ":type" => $Type, ":sub" => $sub_Type, ":prop1" => $itemAttrib1, ":val1" => $val_1, ":val2" => $val_2, ":val3" => $val_3, ":val4" => $val_4, ":val5" => $val_5, ":val6" => $val_6, ":val7" => $val_7, ":val8" => $val_8, ":prop2" => $itemAttrib2, ":prop3" => $itemAttrib3, ":prop4" => $itemAttrib4, ":prop5" => $itemAttrib5, ":prop6" => $itemAttrib6, ":prop7" => $itemAttrib7, ":prop8" => $itemAttrib8); $ctr = $this->database->DBCtr($sql,$arr); $this->view->count = $ctr; // Lets set how many messages we want to display $per_page = "5"; // Now we must calculate the last page $last_page = ceil($ctr/$per_page); // And set the first page $first_page = "1"; // Here we are making the "First page" link if ($page == $first_page){ $this->view->first = "<li class='disabled'><a href='?page=".$first_page."'>First page</a></li>"; }else{ $this->view->first = "<li><a href='?page=".$first_page."'>First page</a></li>"; } // If page is 1 then remove link from "Previous" word if($page == $first_page){ $this->view->prev = "<li class='disabled'><a>Previous</a></li>"; }else{ if(!isset($page)){ $this->view->prev = "<li><a>Previous</a></li>"; }else{ // But if page is set and it's not 1.. Lets add link to previous word to take us back by one page $previous = $page-1; $this->view->prev = "<li><a href='?page=".$previous."'>Previous</a></li>"; } } // If the page is last page.. lets remove "Next" link if($page == $last_page){ $this->view->next = "<li class='disabled'><a>Next</a></li>"; }else{ // If page is not set or it is set and it's not the last page.. lets add link to this word so we can go to the next page if(!isset($page)){ $next = $first_page+1; $this->view->next = "<li><a href='?page=".$next."'>Next</a></li> "; }else{ $next = $page+1; $this->view->next = "<li><a href='?page=".$next."'>Next</a></li>"; } } // And now lets add the "Last page" link if ($page == $last_page){ $this->view->last = "<li class='disabled'><a href='?page=".$last_page."'>Last page</a></li>"; }else{ $this->view->last = "<li><a href='?page=".$last_page."'>Last page</a></li>"; } // Math.. It gets us the start number of message that will be displayed $start = (($page * $per_page) - $per_page); // Now lets set the limit for our query $limit = "LIMIT $start, $per_page"; $sql = "SELECT * FROM items_us_sc WHERE item_name = :item_name AND quality = :quality AND type = :type AND sub_type = :sub AND ((attrib_1 = :prop1 AND value_1 >= :val1 OR attrib_2 = :prop1 AND value_2 >= :val1 OR attrib_3 = :prop1 AND value_3 >= :val1 OR attrib_4 = :prop1 AND value_4 >= :val1 OR attrib_5 = :prop1 AND value_5 >= :val1 OR attrib_6 = :prop1 AND value_6 >= :val1 OR attrib_7 = :prop1 AND value_7 >= :val1 OR attrib_8 = :prop1 AND value_8 >= :val1) AND (attrib_1 = :prop2 AND value_1 >= :val2 OR attrib_2 = :prop2 AND value_2 >= :val2 OR attrib_3 = :prop2 AND value_3 >= :val2 OR attrib_4 = :prop2 AND value_4 >= :val2 OR attrib_5 = :prop2 AND value_5 >= :val2 OR attrib_6 = :prop2 AND value_6 >= :val2 OR attrib_7 = :prop2 AND value_7 >= :val2 OR attrib_8 = :prop2 AND value_8 >= :val2) AND (attrib_1 = :prop3 AND value_1 >= :val3 OR attrib_2 = :prop3 AND value_2 >= :val3 OR attrib_3 = :prop3 AND value_3 >= :val3 OR attrib_4 = :prop3 AND value_4 >= :val3 OR attrib_5 = :prop3 AND value_5 >= :val3 OR attrib_6 = :prop3 AND value_6 >= :val3 OR attrib_7 = :prop3 AND value_7 >= :val3 OR attrib_8 = :prop3 AND value_8 >= :val3) AND (attrib_1 = :prop4 AND value_1 >= :val4 OR attrib_2 = :prop4 AND value_2 >= :val4 OR attrib_3 = :prop4 AND value_3 >= :val4 OR attrib_4 = :prop4 AND value_4 >= :val4 OR attrib_5 = :prop4 AND value_5 >= :val4 OR attrib_6 = :prop4 AND value_6 >= :val4 OR attrib_7 = :prop4 AND value_7 >= :val4 OR attrib_8 = :prop4 AND value_8 >= :val4) AND (attrib_1 = :prop5 AND value_1 >= :val5 OR attrib_2 = :prop5 AND value_2 >= :val5 OR attrib_3 = :prop5 AND value_3 >= :val5 OR attrib_4 = :prop5 AND value_4 >= :val5 OR attrib_5 = :prop5 AND value_5 >= :val5 OR attrib_6 = :prop5 AND value_6 >= :val5 OR attrib_7 = :prop5 AND value_7 >= :val5 OR attrib_8 = :prop5 AND value_8 >= :val5) AND (attrib_1 = :prop6 AND value_1 >= :val6 OR attrib_2 = :prop6 AND value_2 >= :val6 OR attrib_3 = :prop6 AND value_3 >= :val6 OR attrib_4 = :prop6 AND value_4 >= :val6 OR attrib_5 = :prop6 AND value_5 >= :val6 OR attrib_6 = :prop6 AND value_6 >= :val6 OR attrib_7 = :prop6 AND value_7 >= :val6 OR attrib_8 = :prop6 AND value_8 >= :val6) AND (attrib_1 = :prop7 AND value_1 >= :val7 OR attrib_2 = :prop7 AND value_2 >= :val7 OR attrib_3 = :prop7 AND value_3 >= :val7 OR attrib_4 = :prop7 AND value_4 >= :val7 OR attrib_5 = :prop7 AND value_5 >= :val7 OR attrib_6 = :prop7 AND value_6 >= :val7 OR attrib_7 = :prop7 AND value_7 >= :val7 OR attrib_8 = :prop7 AND value_8 >= :val7) AND (attrib_1 = :prop8 AND value_1 >= :val8 OR attrib_2 = :prop8 AND value_2 >= :val8 OR attrib_3 = :prop8 AND value_3 >= :val8 OR attrib_4 = :prop8 AND value_4 >= :val8 OR attrib_5 = :prop8 AND value_5 >= :val8 OR attrib_6 = :prop8 AND value_6 >= :val8 OR attrib_7 = :prop8 AND value_7 >= :val8 OR attrib_8 = :prop8 AND value_8 >= :val8)) $limit"; $arr = array(":item_name" => $itemName, ":quality" => $Quality, ":type" => $Type, ":sub" => $sub_Type, ":prop1" => $itemAttrib1, ":val1" => $val_1, ":val2" => $val_2, ":val3" => $val_3, ":val4" => $val_4, ":val5" => $val_5, ":val6" => $val_6, ":val7" => $val_7, ":val8" => $val_8, ":prop2" => $itemAttrib2, ":prop3" => $itemAttrib3, ":prop4" => $itemAttrib4, ":prop5" => $itemAttrib5, ":prop6" => $itemAttrib6, ":prop7" => $itemAttrib7, ":prop8" => $itemAttrib8); $this->view->items = $this->database->DBQry($sql,$arr); $this->view->msg = "Successful Search"; $this->view->err = true; $this->view->render('Search/Index'); } } ?> here is the "Search/Index" View: <?php include_once("views/Header.php"); ?> <div class="container"> <?php if($this->err == true): ?> <div class="alert alert-success alert-dismissable"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> <?php echo $this->msg; ?> </div> <?php else: ?> <div class="alert alert-danger alert-dismissable"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> <?php echo $this->msg; ?> </div> <?php endif ?> <div class="well well-sm"> <div class="row col-xs-12"> <div class="btn-group"> <a class="btn btn-danger dropdown-toggle" data-toggle="dropdown" href="#" style="font-weight: normal;"><?php if ($url == '/us/sc') { ?>US Softcore<?php }elseif ($url == '/us/hc') { ?> US Hardcore <?php } ?> <span class="caret"></span> </a> <ul class="dropdown-menu open" style="padding: 5px;"> <li><a href="<?php echo $ahurl; ?>/sc">US Softcore</a></li> <li class="divider"></li> <li><a href="<?php echo $ahurl;?>/hc">US Hardcore</a></li> </ul> </div> </div> </div> <?php include("models/ItemSearch.php"); ?> <div class="row"> <div class="col-md-8"> <!-- Item --> <?php $count = 0; if (count($this->items)%3!=0) { //Append 1 or 2 items from start of array if needed } ?><div class="row"> <?php foreach ($this->items as $item): if (($count>0) and ($count%3==0)): ?></div><div class="row"><?php endif; ?><div class='col-md-4'> <div class="thumbnail"> <h4 <?php if ($item['quality'] == 'Legendary'): ?> class="item-title quality-orange" <?php elseif ($item['quality'] == 'Set'): ?> class="item-title quality-green" <?php elseif ($item['quality'] == 'Rare'): ?> class="item-title quality-yellow" <?php endif ?>><a class="item-title" style="text-decoration:none;" href="<?php echo $this->url; ?>Item-<?php echo $item['item_num']; ?>"><?php echo $item['item_name']; ?></a></h4> <a href="<?php echo $this->url; ?>Item-<?php echo $item['item_num']; ?>"> <img <?php if ($item['quality'] == 'Legendary'): ?> class="item-icon quality-orange" <?php elseif ($item['quality'] == 'Set'): ?> class="item-icon quality-green" <?php elseif ($item['quality'] == 'Rare'): ?> class="item-icon quality-yellow" <?php endif ?> src="<?php echo $this->url.$item['item_img']; ?>" align="left" /></a> <div class="caption"> <?php if ($item['armor'] == NULL){ echo ''; }else{ ?> <ul class="stat-basic"><li class="armor"><?php echo $item['armor']; ?></li>Armor</ul> <?php }if ($item['dps'] == NULL && $item['min_max'] == NULL && $item['aps'] == NULL){ echo ''; }else{ ?> <ul class="stat-basic"> <li class="dmg"><?php echo $item['dps']; ?></li><li class="dps"> Damage Per Second</li> <li><?php echo $item['min_max']; ?> Damage</li> <li><?php echo $item['aps']; ?> Attacks Per Second</li> </ul> <?php }?> <div class="prop"> <ul class="item-attrib"> <?php if($item['attrib_1'] == 'None' || $item['attrib_1'] == '' || $item['attrib_1'] == 'none' || $item['attrib_1'] == 'Has Sockets'){ echo ''; }else{ ?> <li><img src="<?php echo $this->url."img/bullet.gif"; ?>"> +<?php echo $item['value_1']; ?> <?php echo $item['attrib_1']; ?></li> <?php }if ($item['attrib_2'] == 'None' || $item['attrib_2'] == '' || $item['attrib_2'] == 'none' || $item['attrib_2'] == 'Has Sockets'){ echo ''; }else{ ?> <li><img src="<?php echo $this->url."img/bullet.gif"; ?>"> +<?php echo $item['value_2']; ?> <?php echo $item['attrib_2']; ?></li> <?php }if ($item['attrib_3'] == 'None' || $item['attrib_3'] == '' || $item['attrib_3'] == 'none' || $item['attrib_3'] == 'Has Sockets'){ echo ''; }else{ ?> <li><img src="<?php echo $this->url."img/bullet.gif"; ?>"> +<?php echo $item['value_3']; ?> <?php echo $item['attrib_3']; ?></li> <?php }if ($item['attrib_4'] == 'None' || $item['attrib_4'] == '' || $item['attrib_4'] == 'none' || $item['attrib_4'] == 'Has Sockets'){ echo ''; }else{ ?> <li><img src="<?php echo $this->url."img/bullet.gif"; ?>"> +<?php echo $item['value_4']; ?> <?php echo $item['attrib_4']; ?></li> <?php }if ($item['attrib_5'] == 'None' || $item['attrib_5'] == '' || $item['attrib_5'] == 'none' || $item['attrib_5'] == 'Has Sockets'){ echo ''; }else{ ?> <li><img src="<?php echo $this->url."img/bullet.gif"; ?>"> +<?php echo $item['value_5']; ?> <?php echo $item['attrib_5']; ?></li> <?php }if ($item['attrib_6'] == 'None' || $item['attrib_6'] == '' || $item['attrib_6'] == 'none' || $item['attrib_6'] == 'Has Sockets'){ echo ''; }else{ ?> <li><img src="<?php echo $this->url."img/bullet.gif"; ?>"> +<?php echo $item['value_6']; ?> <?php echo $item['attrib_6']; ?></li> <?php }if ($item['attrib_7'] == 'None' || $item['attrib_7'] == '' || $item['attrib_7'] == 'none' || $item['attrib_7'] == 'Has Sockets'){ echo ''; }else{ ?> <li><img src="<?php echo $this->url."img/bullet.gif"; ?>"> +<?php echo $item['value_7']; ?> <?php echo $item['attrib_7']; ?></li> <?php }if ($item['attrib_8'] == 'None' || $item['attrib_8'] == '' || $item['attrib_8'] == 'none' || $item['attrib_8'] == 'Has Sockets'){ echo ''; }else{ ?> <li><img src="<?php echo $this->url."img/bullet.gif"; ?>"> +<?php echo $item['value_8']; ?> <?php echo $item['attrib_8']; ?></li> <?php }if ($item['attrib_1'] == 'Has Sockets' && $item['value_1'] == 3){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_1'] == 'Has Sockets' && $item['value_1'] == 2){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_1'] == 'Has Sockets' && $item['value_1'] == 1){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_2'] == 'Has Sockets' && $item['value_2'] == 3){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_2'] == 'Has Sockets' && $item['value_2'] == 2){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_2'] == 'Has Sockets' && $item['value_2'] == 1){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_3'] == 'Has Sockets' && $item['value_3'] == 3){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_3'] == 'Has Sockets' && $item['value_3'] == 2){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_3'] == 'Has Sockets' && $item['value_3'] == 1){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_4'] == 'Has Sockets' && $item['value_4'] == 3){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_4'] == 'Has Sockets' && $item['value_4'] == 2){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_4'] == 'Has Sockets' && $item['value_4'] == 1){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_5'] == 'Has Sockets' && $item['value_5'] == 3){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_5'] == 'Has Sockets' && $item['value_5'] == 2){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_5'] == 'Has Sockets' && $item['value_5'] == 1){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_6'] == 'Has Sockets' && $item['value_6'] == 3){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_6'] == 'Has Sockets' && $item['value_6'] == 2){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_6'] == 'Has Sockets' && $item['value_6'] == 1){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_7'] == 'Has Sockets' && $item['value_7'] == 3){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_7'] == 'Has Sockets' && $item['value_7'] == 2){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_7'] == 'Has Sockets' && $item['value_7'] == 1){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_8'] == 'Has Sockets' && $item['value_8'] == 3){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_8'] == 'Has Sockets' && $item['value_8'] == 2){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_8'] == 'Has Sockets' && $item['value_8'] == 1){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php } ?> </ul> </div> </div> </div> </div><?php $count++; endforeach; ?> <!-- end item --> </div> </div> <ul class="pager"> <?php echo $this->first; echo $this->prev; echo $this->next; echo $this->count; echo $this->last; ?> </ul> </div> </div> </div> <?php include_once("views/Footer.php"); ?>
  11. I'm about to update my search script. The search engine searches in my database where I ask it to search. What is new is I want do some search words, that the users can check in a checkbox, if he wants to use the word in the search. As for now my search engine works, the only problem is that it only searches the last word and not all of the checked words. My formula looks like this: <form method="POST" action="<?=$_SERVER["PHP_SELF"]?>"> <p>Search for: </p> Books: <input type="checkbox" name='search' value="books"> Movies: <input type="checkbox" name='search' value="movies"> Outdoor: <input type="checkbox" name='search' value="outdoor"> Indore: <input type="checkbox" name='search' value="indore"> </p> <p><input type='submit' value='Search'></p> </form> The php code looks like: <?php if(isset($_POST['search'])) { $connx = mysql_connect('localhost', '*******', ',*********') or die("connx"); $db = mysql_select_db('*********') or die(mysql_error()); # convert to upper case, trim it, and replace spaces with "|": $search = mysql_real_escape_string($search); $search = strtoupper(preg_replace('/\s+/', '|', ($_POST['search']))); # create a MySQL REGEXP for the search: $regexp = "REGEXP '[[:<:]]($search)[[:>:]]'"; $query = "SELECT * FROM `keywords` WHERE UPPER(`keywords01`) $regexp OR ". "`keywords02` $regexp OR ". "`keywords03` $regexp OR ". "`keywords04` $regexp"; $result = mysql_query($query) or die($query . " - " . mysql_error()); echo "<table>\n"; while($row = mysql_fetch_assoc($result)) { echo "<tr>"; echo "<td><img src=../{$row['type']}/{$row['folder']}/{$row['date']}-{$row['num']}/{$row['thumbimage']} border=1></td>"; echo "<td>{$row['name']}</td>"; echo "<td>{$row['date']}</td>"; echo "<td><a href=../view.php?id={$row['id']} target=blank>VIEW</a></td>"; echo "</tr>\n"; } } else { echo "<p>Sorry, no results matched your search.</p>"; } ?> Are there someone, who can figure out, why it is only the last marked checkboxs word that are searched and not all marked words and how do I get it to search for all marked words? Hope someone can help.
  12. Hi, I have built an application in PHPRunner. Everything is ok except on my search facility. Normal Search works fine. However when ever I try to search by a specific column I get the error message: - ForbiddenYou don't have permission to access /pgcommission/tblworklistV2_list.php on this server. I have taken advice and read several forums etc and I am told it is due to File Permissions. I have tried every combination I can on both my _List.php and _search.php files for the respective Table but to no avail. Is there someone out there that can give me a fresh perspective on this and make suggestions? Many thanks desperate, Carl.
  13. Hi, I'm having difficulty with some PHP coding I have put together. I have a HTML search form that allows users to search a MySQL DB for a value and posts the value to a PHP page, this then displays the results. This part of my code is working. My problem is the second half of what I want to do. I have added a submit button for each record that is displayed so that if the user selects that result it increments a value in the row to show how many times it has been selected. At the minute it always updates the last record rather than the one selected, I can't work out why this is as I have set the update query to update when equal to the id of that row. A second issue is that after clicking submit the page then displays all records from the database rather than those previously displayed after the initial search. If anyone could point out where I'm going wrong I'd appreciate it. Thanks, here is my code; <?php mysql_connect ("localhost", "USERNAME","PASSWORD") or die (mysql_error()); mysql_select_db ("DBNAME"); $term = $_POST['term']; $sql = mysql_query("select * from TABLE where point like '%$term%' or point2 like '%$term%' or point3 like '%$term%' "); echo "here are your results for"; echo "<br>"; echo "search criteria: "; echo $term; echo "<br>"; echo " "; while ($row = mysql_fetch_array($sql)){ $chosen = $row['choice']; $id = $row['id']; echo '<form name="form1" id="form1" method="POST" action="">'; echo "<table>"; echo "<tr>"; echo '<td> 1 </td>'; echo '<td> 2 </td>'; echo '<td> 3 </td>'; echo '<td> 4 </td>'; echo '<td> 5 </td>'; echo '<td> 6 </td>'; echo "<tr>"; echo "<td>" .$row['field1']."</td>"; echo "<td>" .$row['field2']."</td>"; echo "<td>" .$row['field3']."</td>"; echo "<td>" .$row['field4']."</td>"; echo "<td>" .$row['field5']."</td>"; echo "<td>" .$row['id']."</td>"; echo "<tr>"; echo '<td colspan="6"> <input type = "submit" id="submit" name="submit" value="submit"> </td>'; echo "</table>"; echo "</form>"; echo "<br>"; } if (isset($_POST['submit'])) { $likes = $liked+1; $insert= mysql_query("UPDATE Players SET choice='$chosen' WHERE id=$id"); } ?>
  14. Hi all, I am new here and have a question. I have created a search tool for a database table which I am currently searching through the Description column in the table but would like to add the Title, and the Category columns as well. My script is below. it searches, creates the table adn displays adn paginates perfectly, but as soon as I try to add more variables it crashes. It seems to be in the $construct variable I am building to fetch adn display the results. Any assistance would be great. I would like to be able to, in index.php search feild, put Burger and it would look through Title, Catagory, adn Description within the table and display the results. This is the Index.php script <html> <head> <title>RECIPE SEARCH</title> </head> <body> <form action='search.php' method='GET'> <center> <h1>CHEF JAMIE RECIPE SEARCH TOOL</h1><br/> <h4>Currently searching through recipe ingredients.</h4> <input type='text' size='50' name='search'></br></br> <input type='submit' name='submit' value='Search source code' ></br></br></br> </center> </form> </body> </html> And this is the search.php page <?php $button = $_GET ['submit']; $search = $_GET ['search']; if(strlen($search)<=1) echo "Search term too short"; else{ echo "You searched for <b>$search</b> <hr size='1'></br>"; mysql_connect("localhost","xxxx","xxxxxx!"); mysql_select_db("chefjami_CJG2"); $search_exploded = explode (" ", $search); foreach($search_exploded as $search_each) { $x++; if($x==1) $construct .="Description LIKE '%$search_each%'"; else $construct .="AND Description LIKE '%$search_each%'"; } $constructs ="SELECT * FROM recipes WHERE $construct"; $run = mysql_query($constructs); $foundnum = mysql_num_rows($run); if ($foundnum==0) echo "Sorry, there are no matching result for <b>$search</b>.</br></br>1. Try more general words. for example: If you want to search 'how to create a website' then use general keyword like 'create' 'website'</br>2. Try different words with similar meaning</br>3. Please check your spelling. </br>4. <a href='index.php'>Go back to search</a>"; else { echo "$foundnum results found ! <a href='index.php'>Go back to search</a><p>"; $per_page = 1; $start = $_GET['start']; $max_pages = ceil($foundnum / $per_page); if(!$start) $start=0; $getquery = mysql_query("SELECT * FROM recipes WHERE $construct LIMIT $start, $per_page"); while($runrows = mysql_fetch_assoc($getquery)) { $Title = $runrows ['Title']; $Description = $runrows['Description']; $Catagory = $runrows ['Catagory']; echo " <b><h3>$Title</h3></b><br> $Description<br> <strong>Category: $Catagory</strong><p> <hr> "; } //Pagination Starts echo "<center>"; $prev = $start - $per_page; $next = $start + $per_page; $adjacents = 3; $last = $max_pages - 1; if($max_pages > 1) { //previous button if (!($start<=0)) echo " <a href='search.php?search=$search&submit=Search+source+code&start=$prev'>Prev</a> "; //pages if ($max_pages < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up { $i = 0; for ($counter = 1; $counter <= $max_pages; $counter++) { if ($i == $start){ echo " <a href='search.php?search=$search&submit=Search+source+code&start=$i'><b>$counter</b></a> "; } else { echo " <a href='search.php?search=$search&submit=Search+source+code&start=$i'>$counter</a> "; } $i = $i + $per_page; } } elseif($max_pages > 5 + ($adjacents * 2)) //enough pages to hide some { //close to beginning; only hide later pages if(($start/$per_page) < 1 + ($adjacents * 2)) { $i = 0; for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) { if ($i == $start){ echo " <a href='search.php?search=$search&submit=Search+source+code&start=$i'><b>$counter</b></a> "; } else { echo " <a href='search.php?search=$search&submit=Search+source+code&start=$i'>$counter</a> "; } $i = $i + $per_page; } } //in middle; hide some front and some back elseif($max_pages - ($adjacents * 2) > ($start / $per_page) && ($start / $per_page) > ($adjacents * 2)) { echo " <a href='search.php?search=$search&submit=Search+source+code&start=0'>1</a> "; echo " <a href='search.php?search=$search&submit=Search+source+code&start=$per_page'>2</a> .... "; $i = $start; for ($counter = ($start/$per_page)+1; $counter < ($start / $per_page) + $adjacents + 2; $counter++) { if ($i == $start){ echo " <a href='search.php?search=$search&submit=Search+source+code&start=$i'><b>$counter</b></a> "; } else { echo " <a href='search.php?search=$search&submit=Search+source+code&start=$i'>$counter</a> "; } $i = $i + $per_page; } } //close to end; only hide early pages else { echo " <a href='search.php?search=$search&submit=Search+source+code&start=0'>1</a> "; echo " <a href='search.php?search=$search&submit=Search+source+code&start=$per_page'>2</a> .... "; $i = $start; for ($counter = ($start / $per_page) + 1; $counter <= $max_pages; $counter++) { if ($i == $start){ echo " <a href='search.php?search=$search&submit=Search+source+code&start=$i'><b>$counter</b></a> "; } else { echo " <a href='search.php?search=$search&submit=Search+source+code&start=$i'>$counter</a> "; } $i = $i + $per_page; } } } //next button if (!($start >=$foundnum-$per_page)) echo " <a href='search.php?search=$search&submit=Search+source+code&start=$next'>Next</a> "; } echo "</center>"; } } ?>
  15. hay there How can i check for say 2 or more words in a string... Now I know this checks for 2 words on a "OR" basis if(preg_match("/$findthis|$this/i", $text_to_search)) { //do something } So this ill check to see if the $text_to_search contains either $findthis or $this but i need it to check with the "and" operator - so for example.. search $text_to_search for $findthis and $this how can i do this? many thanks
  16. Hi, I have cobbled together the code from two tutorials, both of which work superbly on their own, but I must have something wrong in the code because together they don't work. I have a database of chillies which is searchable. I want to add pagination when the results returned exceed 10. The problem is the first page of results returns 10 as it should, and at the bottom of the page there is the option to go to page two or next, but when you do, page 2 has no results and when you return to page one there are no results either. The code is as follows; <h1>Chilli Search Results</h1> <?php // Initilise search output variable $search_output = ""; // Process the search query if(isset($_POST['searchquery'])) { // Filter user input $searchquery = preg_replace('#[^a-z 0-9?]#i', '', $_POST['searchquery']); $heat = $_POST['heat']; // Select Database mysql_select_db("allotmen_content") or die (mysql_error()); if($heat != 'any'){ $sqlcommand = "SELECT id, image1, common_name, url, url_short FROM chillies WHERE common_name LIKE '%$searchquery%' AND heat = '$heat'"; }else{ $sqlcommand = "SELECT id, image1, common_name, url, url_short FROM chillies WHERE common_name LIKE '%$searchquery%'"; } $query = mysql_query($sqlcommand) or die(mysql_error()); $count = mysql_num_rows($query); if(empty($_POST['searchquery'])) { // If search box is empty echo 'Search box can not be empty. Please go back and enter some text <a href="chillies-homepage.php">BACK</a> <br /><br />'; // If count is greater than 0 }else if($count > 0) { $search_output .= "<hr /> $count Results for <strong>$searchquery</strong><hr /><br /><br />"; if (isset($_GET['pn'])) { // Get pn from URL vars if it is present $pn = preg_replace('#[^0-9]#i', '', $_GET['pn']); // filter everything but numbers for security(new) //$pn = ereg_replace("[^0-9]", "", $_GET['pn']); // filter everything but numbers for security(deprecated) } else { // If the pn URL variable is not present force it to be value of page number 1 $pn = 1; } //This is where we set how many database items to show on each page $itemsPerPage = 10; // Get the value of the last page in the pagination result set $lastPage = ceil($count / $itemsPerPage); // Be sure URL variable $pn(page number) is no lower than page 1 and no higher than $lastpage if ($pn < 1) { // If it is less than 1 $pn = 1; // force if to be 1 } else if ($pn > $lastPage) { // if it is greater than $lastpage $pn = $lastPage; // force it to be $lastpage's value } // This creates the numbers to click in between the next and back buttons // This section is explained well in the video that accompanies this script $centerPages = ""; $sub1 = $pn - 1; $sub2 = $pn - 2; $add1 = $pn + 1; $add2 = $pn + 2; if ($pn == 1) { $centerPages .= ' <span class="pagNumActive">' . $pn . '</span> '; $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '">' . $add1 . '</a> '; } else if ($pn == $lastPage) { $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '">' . $sub1 . '</a> '; $centerPages .= ' <span class="pagNumActive">' . $pn . '</span> '; } else if ($pn > 2 && $pn < ($lastPage - 1)) { $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub2 . '">' . $sub2 . '</a> '; $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '">' . $sub1 . '</a> '; $centerPages .= ' <span class="pagNumActive">' . $pn . '</span> '; $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '">' . $add1 . '</a> '; $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add2 . '">' . $add2 . '</a> '; } else if ($pn > 1 && $pn < $lastPage) { $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '">' . $sub1 . '</a> '; $centerPages .= ' <span class="pagNumActive">' . $pn . '</span> '; $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '">' . $add1 . '</a> '; } // This line sets the "LIMIT" range... the 2 values we place to choose a range of rows from database in our query $limit = 'LIMIT ' .($pn - 1) * $itemsPerPage .',' .$itemsPerPage; // Now we are going to run the same query as above but this time add $limit onto the end of the SQL syntax // $sql2 is what we will use to fuel our while loop statement below $sql2 = mysql_query("$sqlcommand ORDER BY common_name ASC $limit"); $paginationDisplay = ""; // Initialize the pagination output variable // This code runs only if the last page variable is ot equal to 1, if it is only 1 page we require no paginated links to display if ($lastPage != "1"){ // This shows the user what page they are on, and the total number of pages $paginationDisplay .= 'Page <strong>' . $pn . '</strong> of ' . $lastPage. ' '; // If we are not on page 1 we can place the Back button if ($pn != 1) { $previous = $pn - 1; $paginationDisplay .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $previous . '"> Back</a> '; } // Lay in the clickable numbers display here between the Back and Next links $paginationDisplay .= '<span class="paginationNumbers">' . $centerPages . '</span>'; // If we are not on the very last page we can place the Next button if ($pn != $lastPage) { $nextPage = $pn + 1; $paginationDisplay .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $nextPage . '"> Next</a> '; } } while($row = mysql_fetch_array($sql2)) { $id = $row["id"]; $image = $row["image1"]; $title = $row["common_name"]; $url = $row["url"]; $url_short = $row["url_short"]; $search_output .= "<a href=\"$url_short\"><img src=\"images/$image\" width=\"100px\" height=\"100px\"/></a> $title - $url <br /><br />"; } // Close while // If no results are found } else { $search_output = "<hr /><br /> Sorry, there are no results for <strong>$searchquery</strong>. <br /><br />Try entering <strong>$searchquery</strong> again but this time select <strong>'ANY HEAT'</strong> as the Heat Level<br /><br /><hr />"; } } ?> <?php echo $search_output; ?> <br /> <?php echo $paginationDisplay; ?> I'm guessing I have have something not quite right, I just can't see it. The page itself can been seen here http://www.allotment-web.org/chillies-homepage.php Search just the letter 'a' to bring more than 10 results and you'll see the issue. There seems little point increasing the number of varieties until I fix this pagination. Any help greatly appreciated. Richard
  17. Hi all I have a very strange situation here... I try to make a string search for a term in utf-8. My search term is "Den lille fløyten" if i use this code: $string = "Den Lille Fløyten"; // The string to search $phrase = "Den lille fløyten"; // The term to search $phrase = preg_replace('/\s+/', '\s+', preg_quote($phrase)); $p = '/\b' . $phrase . '\b/ui'; $result = preg_match($p, $string); // This gives me true (1) everything is OK! But if i put my search term in an array (which i have to do...) and then try to do the search using this search term as an array element i always get false result: $SearchTerms=array('Høstnatt på Fjellskogen', 'Langt Innpå Skoga', 'Den lille fløyten', 'Sølv'); // my array with search terms $string = "Den Lille Fløyten"; // The string to search $phrase = $SearchTerms[2] // The term to search as part of an array $phrase = preg_replace('/\s+/', '\s+', preg_quote($phrase)); $p = '/\b' . $phrase . '\b/ui'; $result = preg_match($p, $string); // This gives me FALSE (0)!!!!!!! Any Ideas? Thanks in advance.
  18. I have a form that searches and subsequently returns data based on the field type selected. The end user can search by city, name, zip, district, county and ID number. Unfortunately I can't get it to trim. Meaning.. if the search term is '3', the return has been: 3, 13, 33, 321, etc.. when it should just return '3'. I have tried and tried, but so far I can only get one of my fields to work properly (intDistrictID). At this point I'm cross eyed Below is the code: <?php $username = "username"; $password = "password"; $hostname = "hostname"; $dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); $selected = mysql_select_db("DB",$dbhandle) or die("Could not select DB"); $metode = mysql_real_escape_string($_POST['metode']); $search = mysql_real_escape_string($_POST['search']); $query = mysql_query("SELECT strLodgeName, intLodgeNumber, intDistrictID, strLodgeLocationCity, strLodgeMailingPostCode FROM tblLodges WHERE TRIM(LEADING '0' FROM $metode) = '$search' GROUP BY strLodgeName LIMIT 50"); while ($row = @mysql_fetch_array($query)) { echo "<tr bgcolor=\"#dddddd\"><td><center>"; echo $row["intLodgeNumber"]; echo "</center></td><td><center>"; echo ltrim($row["strLodgeName"], '0'); echo "</center></td><td><center><span class=\"style2\">"; echo "<input name=\"submit\" type=\"button\" value=\"Lodge Details\" onclick=\"javascript:window.location='http://www.gloklahoma.com/lodgelocator/3view.php?id="; echo $row["intLodgeNumber"]; echo "'\" /></center></td>"; echo "</center></td><td><center>"; echo ltrim($row["strLodgeLocationCity"], '0'); echo $row["strLodgeLocationCity"]; echo "</center></td><td><center>"; echo ltrim($row["intDistrictID"], '0'); }?>
  19. Currently I have a search engine that retrieves results from Bing, Google and Blekko using API keys. To further improve my project I need to apply query expansion or re-writing. There is no way i'm going to create a manual thesaurus. Is there something I could use for this or how would you go about this? Maybe I can use the rewrite functions present in the search engine's?
  20. Hi I have one problem , I need to search any string data . Below my code. When I click, no results as well as no error Index.php <?php include_once '../templete/header.php'; ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Search</title> <link href="style.css" rel="stylesheet" type="text/css" /> </head> <body> <form action="search.php" method="get" > <table border="0" cellpadding="0" cellspacing="0"> <tr> <td><input type="text" name="query" id="text" /> </td> <td><input type="submit" name="submit" id="search" value="Search" /></td> </form> </body> </html> Search.php <?php include_once '../templete/header.php'; include_once '../inc/connection.inc.php'; ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Search</title> <link href="style.css" rel="stylesheet" type="text/css" /> </head> <body> <table> <tr> <td>Name</td> <td>Address</td> </tr> <?php $query = $_GET['query']; $stmt = $dbh->prepare("SELECT * FROM CompanyInfo WHERE (Name LIKE '%".$query."%') OR (Address LIKE '%".$query."%')"); $stmt->setFetchMode(PDO::FETCH_ASSOC); //$stmt->execute(); if(isset($stmt)) { while($row = $stmt->fetch()); ?> <tr> <td><?php echo $row['Name'];?></td> <td><?php echo $row['Address'];?></td> </tr> <?php } ?> </table> </body> </html> Pls help me Maideen
  21. Hi there. I have a small problem, i want to use strrpos and i dont want to make a textbox in the browser so i can write what ever word i want to search for and enter it. here is the code. $string = "Dette er en dummy tekst. Den kan bruges til mange forskellige ting.<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam pellentesque faucibus pretium. Duis vehicula lacus vitae lacus adipiscing dignissim. Suspendisse mauris nulla, vehicula id orci semper, iaculis tincidunt nisl. Quisque congue magna eu elit posuere lacinia eu eget neque. Vivamus est sapien, porta at lacinia eget, commodo vitae lectus. Donec non velit at justo viverra suscipit eu quis purus. Integer tempor lacinia turpis, et aliquet est dignissim non. Aenean euismod dignissim turpis id sollicitudin. Phasellus vitae iaculis orci. Phasellus luctus faucibus tortor vitae porta. Proin semper tristique erat. Suspendisse ac fringilla elit, iaculis condimentum leo. Aliquam sit amet massa non dui congue laoreet eget et libero. Integer viverra nisi a justo tempor sollicitudin. Etiam volutpat aliquet malesuada. Ut erat neque, adipiscing sed dictum ut, commodo vel lacus.</p>"; echo '<h1>Strpos test</h1>'; echo ' <form> <input type="text" placeholder="Search" name="textbox" /> <input type="submit" name="searchButton" value="search" /> </form> '; if(isset($_POST['searchButton'])){ $textbox = $_POST['textbox']; }else{ echo 'type word to search '; } echo '<br />Your result is number '; echo strrpos($string, "word"); But i get the error that i have a Undefined variable: textbox in line 29 How can i make it so that what ever i enter in the textbox form will be the word that is searches for heres a link if you don't know what strrpos is. http://www.w3schools.com/php/func_string_strrpos.asp
  22. Hi, I am trying to build a search page that searches MySQL database. I managed to do the search, but I have a small problem when giving the query. Ex: can someone help me out since I am loosing my mind on this. my sql command is: $SQL = mysql_query("SELECT * FROM stocks WHERE `name` LIKE '%$keywords%' order by code"); help is very appreciated
  23. I'm trying to get some values from a specifc row of an array. My array has this sort of structure: $places = array( array("name" => "Cabot Cove", "area" => "12", "lat" => "-11.003", "lon" => "-151.2285", "pop" => "17"), array("name" => "Smallville", "area" => "32;", "lat" => "-19.910", "lon" => "-50.205", "pop" => "18"), array("name" => "Gotham City", "area" => "85", "lat" => "-39.9294", "lon" => "-40.199", "pop" => "14"), array("name" => "Springfield", "area" => "21.6", "lat" => "-43.9534", "lon" => "-24.2118", "pop" => "18"), ); If a variable $city is set to "Gotham CIty", for example the url of the page could be "/cities/script.php?city=Gotham+City", how do I look through the array and get the "lat" and "lon" values for just this one $city from the array?
  24. How do I search a column for a date which is stored as a var? Is this the best way? $result = mysqli_query($link, " SELECT id, col1, col2, datum, col4, col5, col6, col7, col8, col9 FROM table WHERE `datum` = '$datum' " ) OR die(mysqli_error($link)); Thanks in advance.
  25. Ok, so i am trying to compare a date stored as a variable against a row in mysql, this is where i am so far: I need to be able to search the table for: 1) a search keyword 2) a combination of a date, for example (just 2013) or (march-2012) or (7th of june) or (5th of september 2012) or (just the 16th) etc... $result = mysqli_query($link, " SELECT id, auditor, auditee, datum, department, func, proc, audit_type, copy_to, comments FROM audit_data WHERE ( `auditor` LIKE '%$search_field%' OR `auditee` LIKE '%$search_field%' OR `department` LIKE '%$search_field%' OR `func` LIKE '%$search_field%' OR `proc` LIKE '%$search_field%' OR `audit_type` LIKE '%$search_field%') OR (`id` = '$radio_id') OR (datum = '$datum') " ) OR die(mysqli_error($link)); Its only a small table otherwise I would be indexing. The variable and row are both stored in native format (YYYY-MM-DD) (If i put in a keyword into my $search_field it displays all the rows with a match, that works a treat). The above example shows an exact match between the row and var which as it happen doesnt work. I have a calender setup on the input form and search form that will put in any date like this 2013-04-08 or 2013-00-08 etc. Logically this is what i want (unfortunately doesn't work): if day($datum) = "00" {day($datum) = ""} else { day($datum) = day($_REQUEST['date1'] } if month($datum) = "00" {month($datum) = ""} else { month($datum) = month($_REQUEST['date1'] } if year($datum) = "0000" {year($datum) = ""} else { year($datum) = year($_REQUEST['date1'] } // select select * from audit_data where `datum` = if(isset(day($datum))){day($datum)} OR if(isset(month($datum))){month($datum)} OR if(isset(year($datum))){year($datum)} OR OR [search keyword code here] date1 being the calender output... If the above seem odd, or simply wrong, forgive me, im just trying to get the point across as clear as i can. Can anybody give me a head start on how to do this, any advice, links, examples, structure will be greatly appreciated!
×
×
  • 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.