xCrud : Search Bar - php

I'm currently using and experimenting with xCrud. I'm now wondering, since there is no documentation about those features, if it would be easily possible to have multiple search bars where you can search for different things.
Right now my xCrud file looks like that
<?php
$xcrud->table('table1');
$xcrud->join('ID','table2','ID');
echo $xcrud->render();
?>

Maybe you can use this feature for search different things:
$xcrud->search_columns('productVendor,quantityInStock,buyPrice','quantityInStock');

By default, the xcrud search bar allows you to search all columns in your rendered table. It also allows you to select specific fields to search. The $xcrud->search_columns() function mentioned by #eneskomur is useful when you are displaying data using $xcrud->subselect().

Related

Auto Suggest search implementation

I am working on a content oriented website, I have to implement web search, I am thinking of auto suggest search, like this:
How it can be done?
I want suggestions followed by the search term as in image, I am using lamp stack.
Suggest me some methods to implement this.
Here are the steps:
Write PHP code that will take search keywords and return results in JSON format
Create form in HTML
On every key stroke in search box take search keywords and make AJAX request to search code you made in step 1
Now display the search response you received in JOSN format
http://www.bewebdeveloper.com/tutorial-about-autocomplete-using-php-mysql-and-jquery
To achieve this in your website, you need to know about AJAX and Database in PHP or any other Server Side language. Then you can use Full Text Search in SQL to do the query. So:
PHP mysqli
AJAX
Full Text Search (Match & Against)

Finding images in Wikipedia that are being used across various articles

I'm trying to query wikipedia using MediaWiki api with php (and Curl), in order to search for images that are being used in various articles by a specific search term. For example - search for 'panda', but get only images that are being used somewhere and be able to go to the articles.
I am able to search for images generally using:
https://en.wikipedia.org/w/api.php?action=query&list=allimages&ailimit=100&aifrom=Panda&aiprop=url&format=xmlfm
and I know that basically this should show the usage:
https://commons.wikimedia.org/w/api.php?action=query&prop=images&list=imageusage&iutitle=File:MY_IMAGE_NAME&format=xmlfm
Trying the above does not give me the result I need - I can see a list of images, but I cannot know if or where they are being used.
Can anyone assist?
list=imageusage does not show cross-wiki usage; you'll need prop=globalusage for that. Which is also conveniently a prop module, so it can be folded into the first query using allimages as a generator:
action=query&generator=allimages&gailimit=100&gaifrom=Panda&prop=globalusage
(Omitted prop=images since it does not seem to have any useful purpose.)

Sort, Search(Filter), Paginate HTML Table

I want to sort, paginate and search(search based on a column) a HTML table. I was looking at the various JQuery Plugins like DataTable, TableSorter, Picnet Table Filter, etc. but I couldn't find any plugin which does all the 3 work (Searching, Sorting and Pagination). I have seen such a table in PHP Yii Framework but they have their own CSS and then I will have to convert my rewrite my whole project with Yii. DataTable does have a filter option but that will search a value along all the columns. What I want is to search only in one columns. I am not sure whether I will able to that with DataTable or not. Does anybody know is there any JQuery Plugin for this or any other method to do this
Found this in the demo's of DataTables: http://www.datatables.net/release-datatables/examples/api/multi_filter.html
Should have all 3 of your requirements.
JP list will be the perfect one for your requirement >> https://jplist.com/ .
Those who wants to work around with Divs elements, gallery, other html elements rather than tables , this will be the perfect jQuery plugin for this. This one includes Pagination, Sorting, Filtering and More. All in one package.
Demos : https://jplist.com/demo

Multiple Solr filter queries in PHP

I am trying to use facet in solr, i want to make a search on my database and i need to get articles that belong to specific date and specific publisher.
i used this url on the browser:
localhost:8888/solr//collection1/select/?q=:&version=2.2&start=0&rows=10&indent=on&facet=true&fq=publisher_name:"Saudi Press Agency (SPA)"&fq=datecreated:20110725
and it works fine. I am using (search()) function in apache_solr_service class in my php code. and i set the array as below:
array('facet'=>'true','fq'=>"datecreated:".$date,'fq'=>"publisher_name:\"".$publisher.'"')
I know it wont give me the expected results because of fq index, it will overwrite the value of fq into publisher_name
but how can i set this query with two facet queries
This might help:
http://code.google.com/p/solr-php-client/wiki/FAQ#How_Can_I_Use_Additional_Parameters_%28like_fq,_facet,_etc%29
This is what the code should look like (please check for syntax errors, my PHP is rusty):
array('facet'=>'true','fq'=>array('datecreated:'.$date,'publisher_name:"'.$publisher.'"')
You could also write it like this:
array('fq'=>'+datecreated:'.$date.' +publisher_name:"'.$publisher.'"')
http://wiki.apache.org/solr/CommonQueryParameters#fq
use AND operator:
array('fq'=> 'datecreated:'.$date.' AND publisher_name:"'.$publisher.'"');

getting scriptaculous autocompleter to behave like google instant

You know when you start searching in an autocomplete search box, you get a list of possible results. From those results, say you click one of the items on the list, I want to take that item and perform another search to give another list of results. Just exaclty like how google works. if you dont understand me try typing into google search box something like 'ja'. It will give a list of possible results,when you select one of them, it does another search and gives another set of results.
Pls does anyone know how to do this with scriptalous autocomplete? or anyother way Any example on the net, will really really appreciate it.
I ma using codeigniter frame work (php) by the way
You can definitely do it. Personally I would do it in jQuery using the Autocomplete from jQuery UI.
http://jqueryui.com/demos/autocomplete/
You could get it to load the results like it usually does but format them differently or extend the jquery ui. Would be fairly simple.
Since its possible in jQuery its definitely possible to do with the scriptaculous autocompleter but I am not familiar with it.
You would look at the place where the output is displayed:
<div id="autocomplete_choices" class="autocomplete"></div>
If you can style this the way you want it instead of it being like a dropdown then you will have your instant.

Categories