How can one make one global database query (with PHP) and then use all the output (multiple rows) on various places on a webpage?
I read that javascripts can be called for each specific field on a webpage that needs data, but this is inefficient with regards to performance.
The webpage would contact a sort of table-of-contents with version numbers next to each of them. Those version numbers are stored inside the database and calling the database 20 times for the 20 different fields would be inefficient.
Any suggestions on how to run say a PHP query globally when the page loads and then later in the page use the different output at different locations on the page?
QUESTION UPDATE WITH EXAMPLE OF DESIRED OUTPUT:
The webpage should show the following output:
Document Name Document Version
DEPT A DOCS:
Doc ABC 1.2
- Description of doc
Doc another doc 2.3
- Description of doc
DEPT B DOCS:
Yet another doc 0.9
- Description of doc
Doc XYZ 3.0
- Description of doc
Each of the documents have its own version associated with it. Each document has its own table inside the database with its associated version and this can be queried from a Postgres function or View. I wish to query this function or view only once and then display the results in a sort of 'table-of-contents' style (or table sort of view) on the webpage.
Thank you
P.S. This is my first post here.
Make the query in a separate PHP page that is included in all the pages you want to use the information on.
In the beginning of your page make one database query to get data for all versions.
Using PHP split it into associative array having version number as key.
Then during in different section of your page just apply to that array with version number. output the data the way you need. and it will be the data of this version
Related
I have create a BaseX database and a mytest.xq file containing an XQuery for that database. When I write in my browser the following:
localhost:8984/rest?run=mytest.xq
I get the desired results in an xml form. However I want to perform this using the html language to display those results in a website. Is this possible? If it is, can the results from xml be visualized better for example a table?
I have looked all the documentation regarding baseX http and have not found a way
You can add &method=html to your url like so:
localhost:8984/rest?run=mytest.xq&method=html
As long as you are returning html from your query then it will render with the method argument. You don't need RESTXQ for your simple needs.
The main BaseX page has an example file in the webapp folder called restxq.xqm where you can see how the basic home page is set up. You don't need RESTXQ but you can use the header information from that file in your test query and render your page with that in mind.
Also there is an entire app in the webapp/dba folder that is written entirely in RESTXQ.
I have a page with user data, with ajax pagination using PHP. User's name is listed in descending order(last inserted data will be shown in first page). Suppose there are 3 pages having 2 data's(user name) per page . Imagine, i visited the second page it shows some data, imagine(Alan and Arun - user names). At the same time couple of data is inserted in the database and i requested the 3rd page. But it will show the same data as previous,as a couple of data is inserted in the database. My Question is - How can i handle this. It will create a confusion to the user. Hope you get my point.
One easy solution I could think of would be a timestamp, when you first requested the page. Now you keep this timestamp while navigating through the pages and only display entries older than the timestamp. This way, no new entries would pollute the result and mess with the pagination.
But you'd need to think of a mechanism to let the user include newer entries. E.g. a box display at the top saying "New entries available. Click here to refresh.". A click on this box would refresh the timestamp and navigate back to page 1.
You can create some kind of ping service in JS to see if there is any new update on the server. If there is: fetch it and update in your App. Also, you can create a unique identifier to solve the problem of duplication.
I'm attempting to use the Javascript CSOM to execute several actions from the Item Display Form of a custom list. The intent is to have a button present on the form that will create a subsite based on the displayed item's column data and then add web parts to a "dashboard" page on a top level site page.
I've added a Script Editor web part to the Display Form and created functions that successfully create the subsite and add the web parts when executed manually from the browser console, so now I'm trying to pull it all together and start grabbing data from the list item displayed in the form. I'm having trouble finding the CSOM methods/properties that expose the currently viewed item. I've seen reference to the
_spPageContextInfo.pageListId
property which appears to have a good value for the list I'm looking at but no related property for the actual item being displayed. I've also not seen a good way to directly grab the data from the form elements on the page.
I know that the ListItemID is present somewhere since it's right there in the URL as
DispForm.aspx?ID=5
but I really don't want to do some kind of hacky RegEx on the url if I can avoid it. Is there some kind of page context property that will give me the list ID or the properties of the item being displayed?
I'm not sure if there is a builtin method to get the ID, but there is a SharePoint method for retrieving URL parameters (i.e. no regex "hackery")
GetUrlKeyValue("ID");
Unfortunately, MSDN doesn't have a good reference for this method, but some blogs have some good coverage
https://praneethmoka.wordpress.com/2012/01/12/some-useful-javascript-variablesfunctions-in-sharepoint/
GetUrlKeyValue() is a javascript function using which we can get the
Query string parameter either from url in the browser or a url that we
specify.
parameter(string): query string parameter from the url.
noDecode(bool): specifies whether the value has to be encoded or not.
If false, value is decoded, else returned as it is.(Optional)
url(string): the url from which Query string values are to be
retrieved.(Optional)
use _spPageContextInfo.pageItemId
what happens when a Facebook page is queried for its feed with Facebook Graph API (JS SDK) and a URL parameter fields (like for the post object) is added?
I would like to load from the feed only the posts id's, shares, likes and comments, because the page is pretty active and the text data in JSON for 2 days is about 2MB (25 items)...
I would hope one could do like this: FB.api('/SomePage?fields=id,shares,likes'), but I suppose the only fields you can access are the direct children (for feed, that is data & paging)? If this unfortunately is the case, is there any other way to retrieve all posts from date x to date y without downloading the entire feed?
That's not correct. The feed edge is basically an array of Post objects. You can use the Field Expansion together with time pagination as follows:
GET /{page_id}/feed?fields=id,shares,likes.summary(true)&since={start_unix_timestamp}&until={end_unix_timestamp}
See
https://developers.facebook.com/docs/graph-api/reference/v2.2/page/feed/#read
https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2#fieldexpansion
https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2#paging
As a non-professional programmer, I'm trying to self teach myself a little HTML and javascript. My learning project is a desktop gadget that will retrieve rss items from an rss feed.
I would like an option to toggle so the user of the gadget can decide to display all items or only new items (unread items). It's displaying only the new items that I have a question about.
I realize I have to locally store some kind of data that I can use to compare to the most recent fetch results to see if something is new or not.
What is the typical data that is used in this comparison and is it typically stored in a xml file, or some other kind of file?
Thanks.
In RSS Specifications, guid element should contain a unique identifier for each item, but not all rss feeds respect that, so you may combine that with a date check.
Suggested Simple Storage:
http://example.com/link/to/file.rss guid abcd-ef-12345678
http://example.ord/some/other.rss date 1283647074
This file contains info on the last item of each rss feed in the gadget, space separated (you can comma-separate them as in .csv files as well), first field is the RSS URL, second is the method used to check last item, either via guid or via pubDate, last is the value to check. In the sample file I put the timestamp instead of the pubDate that arrives, for storage purposes.