$_SERVER[QUERY_STRING] copying itself - html

This is the part of the code for paging(when you see page 1,page 2...at the bottom).The $_SERVER[QUERY_STRING] is used to copy what was searched on previous page so that page number 2 displays results for same query.
The problem is that on page 2 the "query string" is added with page number &page=2 so when you click for page 3 the $_SERVER[QUERY_STRING] copies the query(which i need to be copied,eg. ?search=salad)and the page number(which is unnecessary),it looks like this &page=2&page=3
Is there any good way to do this?...it would be nice if something could change only the number of page instead copying whole word.
<a href='$_SERVER[PHP_SELF]?$_SERVER[QUERY_STRING]?start=$back'><font face='Verdana' size='2'>PREV</font></a>

$query = http_build_query(array('page' => $num) + $_GET);
printf('Prev', $_SERVER['PHP_SELF'], $query);
This uses the $_GET array, which contains all the values of $_SERVER['QUERY_STRING'] in a neat array, "overwrites" the page value of that array, then re-assembles it into a URL-encoded query string.

Related

What does the "ved" parameter in a google search refer to?

I've spent like two hours or more trying to figure out what a "ved" parameter on a Google search means. A curious person I am.
My finds so far:
$ved value changes-
1 - every different search result (diff keywords)
2 - every different resulted block (the url blocks/boxed on the resulted google search, but they are quite similar, as I'll write down below)
3 - every different geolocation perhaps
Consider these tests or lookups:
1-
Diff keywords, but first block/position in list:
&ved=2ahUKEwidsaSd4M_1AhVlk_0HHUxOCQYQFnoECAsQAg
&ved=2ahUKEwj2pZyN5s_1AhVRmuYKHZ5IB5EQFnoECAcQAg
I thought the "ved" value refers to the block/position of a url in the result list, but no.
2-
Twree different urls, first and second from the 1st and 2nd blocks of first page, then third from a "much farther on the list" block:
ved=2ahUKEwjq1-Wb1s_1AhW6SWwGHZwpBMwQFnoECD8QAQ
ved=2ahUKEwjq1-Wb1s_1AhW6SWwGHZwpBMwQFnoECCAQAQ
ved=2ahUKEwiZ2NDe1s_1AhVaTmwGHThIA5U4PBAWegQIGRAB
The same website url, from different countries (not considering blocks or position in list):
&ved=2ahUKEwiopK2X08_1AhUgxzgGHQEbDkcQFnoECBIQAQ
&ved=2ahUKEwjpueqC1M_1AhWJq3IEHYEDAfc4FBAWegQIDBAB
&ved=2ahUKEwih09Wz08_1AhUY7WEKHQYdBB8QFnoECEIQAQ
Very similar they are.
I'd really love to know what they mean. Any ideas are appreciated too!
I found an interesting article explaining the subject : https://moz.com/blog/inside-googles-ved-parameter
TL;DR:
A ved code contains up to five separate parameters, which each tell you something about the link that was clicked on:
1st (parameter1: Link index) gives you an idea of where the link was on the page.
2nd (parameter2: Link type) is a number that corresponds to the 'type' of the link that was clicked.
3rd (parameter7: Start result position) is the cumulative result position of the first result on the page.
4th (parameter 6: Result position) indicates the position of your page in the search results.
5th (parameter 5: Sub-result position) like the (parameter 6), except it tells you the position in a list of sub-results, such as breadcrumbs, or one-page sitelinks.

HTML: How to show a list whose size is unknown in advance on a webpage?

I'm like to admit that my knowledge of HTML is very little.
Assume we have a button on our pagepage that calls a javascript function: check().
The check() function withdraws an array (contantly updated) of values, e.g. string, from a server. If each element of the array has a certain property, e.g. contain a letter "a", then it wants to print those strings on the webpage.
The upperbound of the array size retrieved from the server is known but we do not know in advance how many elements satisfies the condition checked by check().
Question how to print the elements found by check() on a HTML file (a webpage).
Let's assume javascrip is in the the HTLM file too.
With something like <div id="destination"></div> in the HTML as a placeholder, you can use JavaScript to loop through your array of items and insert each one into the HTML with:
document.getElementById('destination').innerHTML += '<p>' + myData + '</p>';

xpath scraping data from the second page

I am trying to scrape data from this webpage: http://webfund6.financialexpress.net/clients/zurichcp/PortfolioPriceTable.aspx?SchemeID=33, and I specifically need data for fund number 26.
Have no problem getting data from the first page with this address (funds number 1-25), but for the hell of me can't scrape anything from the second page. Can someone help?
Thanks!
Here is the code I use: in Google Sheets:
=IMPORTXML("http://webfund6.financialexpress.net/clients/zurichcp/PortfolioPriceTable.aspx?SchemeID=33","/html/body/form[#id='MainForm']/table/tr/td/div[#id='main']/div[#id='tabResult']/div[#id='Prices']/table/thead/tr[26]/td[#class='Center'][1]")
You can do 2 things - one is to append the PgIndex=2 onto the end of your URL, and then you can also significantly simplify your xpath to this:
//*[#id='Prices']//tr[2]/td[2]
This specifically grabs the second row on the table (tr which means table-row), in order to bypass the header row, then grabs the second field which is the table-data cell.
=IMPORTXML("http://webfund6.financialexpress.net/clients/zurichcp/PortfolioPriceTable.aspx?SchemeID=33&PgIndex=2","//*[#id='Prices']//tr[2]/td[2]")
To get the second page, add &PgIndex=2 to your url. Then adjust the /table/thead/tr[26] to /table/thead/tr[2]. The result is:
=IMPORTXML("http://webfund6.financialexpress.net/clients/zurichcp/PortfolioPriceTable.aspx?SchemeID=33&PgIndex=2","/html/body/form[#id='MainForm']/table/tr/td/div[#id='main']/div[#id='tabResult']/div[#id='Prices']/table/thead/tr[2]/td[#class='Center'][1]")

VBA Word Asynchronous Execution

I have a form in MS Access that allows users to enter data they collect from the field and that form also has the option to compile all of the information into a formal report. The report contains a cover sheet and a table of contents as well as leaves section header pages for additional documents to be attached when printed out/exported.
There are 2 things that execute before their processes are actually finished:
One subroutine creates many formatted tables but the tables only get created with the appropriate data, the formatting does not apply right away and as a result, the formatting finally kicks in once the document is done typing and will delete any extra pages. This is affecting the second problem.
Since the page numbering for each page is not the same, sections are used so that each page can have a unique footer with the page number included in that. A loop is used to run through the document and unlink all headers and footers from the previous ones. It then starts from the beginning of the document and moves from footer to footer and writes the page number. That code is below:
While Not Selection.Information(wdActiveEndPageNumber)
If Selection.Information(wdActiveEndPageNumber) = (Section_Page + 1) Then
Selection.TypeText "Page: " & (pgNum + Section_Length)
pgNum = pgNum + Section_Length
Else
Selection.TypeText "Page: " & pgNum
End If
pgNum = pgNum + 1
ActiveWindow.ActivePane.View.NextHeaderFooter 'move to the next page's footer
Wend
The problem that I am having with this section of code is that the Selection does not always move to the next footer fast enough and as a result footers that belong on the next page sometimes cram onto the same page as another footer and the footer looks something like "Page: 5Page: 6" rather than "Page: 5" on one and "Page: 6" on the next.
Please do not suggest the built in Word page numbering - I shortened the code here, there are anywhere between 3 and 7 sections that need spacing. I think if there was a way to get the code to execute asynchronously that block of code will work.
A stop-gap measure would be to insert one (or several) line(s) of
DoEvents
after the change and before ActiveWindow....NextHeaderFooter. That command yields execution to the OS. That may give Word the time it needs to catch up.
Of course, you would do better to avoid using ActiveWindow... altogether and iterate through the sections with a For loop.

Duplicate form navigation elements, HTML ID's

I have a table displaying results from a database, and I am adding some paging/navigation buttons to it, such as 'prev', 'next', etc. These are being constructed for now as submit input buttons that are wrapped with a form tag and some hidden inputs to pass the needed querystring values back to the page itself, which means each form and element in the form should have an ID attribute.
Now, I'd love to add the navigation to both the top and bottom of the table, so I've modularized the navigation generation into a single routine I call whenever needed. This of course leads to duplicate form and element IDs in the page when there is more than one navigation bar included.
I've thought of passing some 'count' parameter to the routine so that when generating the HTML it could append that value to the IDs, and there are other solutions, such as using a global counter (ugly), etc, but I thought I'd poll the crowd and see what others have done in this situation.
Thanks,
Paul
Of the solutions you have thought of thus far, I would suggest the tactic that you mention first in the last paragraph. Passing a query string variable and loading X number of records including the number passed (doing error checking of course to make sure that some sneaky user doesn't try to put random characters in the query string) would resolve your issue.
Another option (since you are obviously doing codebehind for loading from the DB) is to create a session variable and assign the value to that when the links are clicked and use it to generate the list.
For both instances, when the page loads you can take the current value being passed and add X (number of rows in results shown +1) and change the value passed by the links.
I recently made a paginator myself, but approached it in a totally different way. I used php to generate the numbers, and each number (page) had a tag with an href that was mywebsite.php?page=x. That way you can use a get method, grab the page number from the url, and loop through as many times as you want for the number of pages displayed.
As they say, there is more than one way to skin a cat. I prefer the url passing method because I can stay away from forms and ID's in their entirety, making it so that the paginator can go wherever I decide to slap it in (and however many times).
Here's a snapshot of how I went about generating it. Hope it gives you some ideas!
/*PAGE NUMBERS*/
// ceil rounds a decimal up to the next integer
$pages=ceil(($totalrows-1)/$tablesize); //we subtract 1 from total rows because it counts 0
//(int) typecasts the $pages variable, so that it is divisible by an integer (ceil makes it a float)
$pages=(int)$pages;
//displays all the pages with their links
//if page count is less than 7 (the full paginator), display all pages
if($pages<=7){
for($i=1;$i<=$pages;$i++){
print "<a class='pages";
//add class current_page if necessary
if($page==$i){print " current_page";}
print "' href='index.php?page=";
print $i. "'>"." $i</a> "." "." ";
}
//if page count is more than 7
}else{
//if page # is less than 4, display pages up to 7, so that there are always 7 pages available (makes the buttons not jump around)
if($page<=4){
for($i=1;$i<=7;$i++){
print "<a class='pages";
//add class current_page if necessary
if($page==$i){print " current_page";}
print "' href='index.php?page=";
print $i. "'>"." $i</a> "." "." ";
}
//if page # is less than 4 away from the end, display pages $pages-7
}elseif($page>=$pages-3){
for($i=$pages-6;$i<=$pages;$i++){
//8,9,10,11,12,13,14,15
print "<a class='pages";
//add class current_page if necessary
if($page==$i){print " current_page";}
print "' href='index.php?page=";
print $i. "'>"." $i</a> "." "." ";
}
//if it's in between the ends, do this
}else{
for($i=1;$i<$pages+1;$i++){
//limit the number of visible pages to 7
if(($i>=$page-3)&&($i<=$page+3)){
print "<a class='pages";
//add class current_page if necessary
if($page==$i){print " current_page";}
print "' href='index.php?page=";
print $i. "'>"." $i</a> "." "." ";
}
}
}
}
There might have been some confusion it seems over what I was looking for, but in a nutshell, a simple way to avoid the duplicate ID issue when using a form-based paging solution that can be displayed multiple times on the same page (above and below tabular data, for example). My solution is to model it after the PHPMyAdmin paging, in that I simply remove the IDs for the form elements for now and reference the data being passed via the name attribute, which allows for duplicates.