Home > OS >  Making a csv file from a html button
Making a csv file from a html button

Time:09-21

I am trying to figure out how to make a csv file when pressing a button, a similar button already exists on the site I am working on but I do not understand the logic behind the redirection, this is what the button that works looks like with it's href:

<a class="btn btn-primary btn-export" href="?csv=1" data-toggle="tooltip" data-placement="bottom" title="Exporter {{pages.total}} élément(s)"><i class="fa fa-table"></i></a>

Could anyone please explain to me how this href can call any particular function or is this an export mode maybe? I'm not sure, any help is greatly appreciated and I will gladly give you guys more info if needed. Thanks!

CodePudding user response:

In an HTTP URL, a ? indicates the start of the query string.

A relative URL consisting entirely of a query string will keep the current path and replace any existing query string with the new one.

e.g. if the current URL is http://example.com/myData.php then the link will resolve to http://example.com/myData.php?csv=1.

Server side code can then process the query string to output different data to the previous URL (which didn't have a query string).

  •  Tags:  
  • html
  • Related