PHP - How to dinamically add a virtual route [closed] - php

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Hi everybody and thanks in advance for your help!
I'm building a php website without using any framework. The site will be multilingual and the client want to add a virtual path for each country, for example: www.mysite.com/ar/ for Argentina, www.mysite.com/cl/ for Chile, and so on. Some languagues will be the same translation, but it has to have his own virtual path. The country will be selected by a select element in HTML, and it has to change the route dinamically.
I was surfing other solutions but they all talk about Rewrite rules in .htaccess, which it's a static solution, but I need something dynamics.
I hope I had explained myself, and you could help me.
Tks !!
/EDIT 06-02-17/
More details as suggested:
I have a table in MySQL with the country. Each record has a code, a name of the country and a virtualPath (is just a string, for example: Code > ARG, Name > Argentina, virtualPath > AR).
In the header of the page, i'm loading a country selector. The user select his country (for ex: Spain) and I want to reload the page, changing the URL to match the virtualPath of the country. For ex: www.mywebsite.com/ES/ or www.mywebsite.com/AR/ and so on.
Hope the detail clears things up! Thanks!!

Sorry for the short answer, I'm short of time but I hope I can point you in the right direction.
Look into REST API;
write yourself a PHP script that can evaluate the URL and then load the appropriate data according to the URL, get the appropriate data or path to data from a database which is updated by the user/client.
Good luck :)

Related

How do I create and run the custom database? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
When I created my pet site and visiting it. I noticed money systems and pet systems all need database for them. But I'm wondering is there any way to create new rows for money system? I need money system for that to purchase virtual pets and itens.
So is there any codes when i click on a thing in the site that adds or removes from database date? Thank you a lot!
I thought that follows that code before I know DB:
<?php
$coin=50;
?>
There are no 'magic buttons' working out of the box - you can get that kind of button but you need to create DB structure, connection, write proper functions/methods (depends on your coding approach) and then bind it to that button.
Even if you are going to use some package/plugin or whatever you find useful - you need to have configured DB to be able to use that.
It is even hard to send you some links with examples/documentation as you did not give any kind of information regarding what (I guess) CMS or service you are using.
Deliver more info and then there is a chance that someone will be able to help.

How to show Only a selected Number of Database entries on the page [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
The question is, if I have got 100 entries in my Database and want them all getting displayed on my page, how can I only show a selected Number like it's the case in webshops etc.
There you've got 37 products e.g. and after 10 products you have to select number 2 of the entry list.Its all split up in a few sites, but its still the same site.How can i achieve this.
You can achieve the pagination either by client side implementations or server side.
Client side (using Java Script/JQuery) and Server Side (using PHP) is preferable.
For client side, just follow this
link
For Server side
PHP Pagination
I notice that you put php, html and mysql as tags on your question so it's mean you don't have a clue on what you are doing. You should really study those things in separate a little more.
For the MySQL part you must study the limit directive.
The html part is not big deal also, you will have to make a pagination system. As said before Google is your friend.
On the server-side (php) you should look for the parameters/url on the page defined by the html part and make the proper query.
If I would enter in details of each of those steps I would have to write several paragraphs and still would be things missing. Well, at least I've given you directions, now you really should study more before attempting to do things like this.
Next time don't ask questions too vague/broad. Try to focus on specific issues rather than asking for the whole solution.

How to implement a database like search form into a website? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
How can I go about implementing a database like search form into an HTML website? For example, there is a form to enter your zip code and after entering the zip code, it searches a .txt file (for example) and returns results that fall under that specific zip code.
Any help would be greatly appreciated.
Thank you
There are many approaches you could take. It's a very broad question.
As an example solution, you would need to have both client and server side code. The client would submit the form to a server. The server code could be written in a multitude of languages, PHP, ASP, JAVA etc.
The server side code would take the request parameters sent by the form, read the file, calculate any result and pass it back in the http response to the front end, which could be dealt with by displaying a new page or as part of an AJAX refresh.
As you can appreciate though, this is a very broad topic and there are many possible solutions.
Also as #Dagon points out, if you are not restricted to using a text file (although your title probably suggests you are) then using a MySQL or other such database could be a better solution, maybe even Solr as an indexing solution, depending on what you are searching for.

automaticly using someones online search database [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Does anyone have any ideas for what would be the best way to automaticly use someones online search database, given a static search (see example). It might also make this question more usefull to add a solution for a none static search.
So for example, I have a website and I wan't to create a link to the PDF file of the latest report by a certain person on this site: http://aris.empr.gov.bc.ca The search criteria does not change, all that changes is new results as the database is updated, so the search result is always http://aris.empr.gov.bc.ca/search.asp?mode=find Notice that not all entries have a report yet.
So far my idea is to use a php script to search through the source code of the completed search result page, search for the first instance of a .pdf string, and then extract the whole link (the page is orderd by date, so the first pdf file found would be the latest report that has a pdf file available.
The problems with this solutions:
1) it is very specific to my problem and only works for a static search result, and so is not a good Q&A
2) I am not sure if the completed search link researches everytime you follow it, or if it leads to an old result that could become out to of date
3) my solution is not sexy and is held together by duct tape, if you know what I mean.
Thanks,
-Adrian
In real terms you want to scrape the page(s).
You have 2 options in PHP:
1. Use CURL to fetch the page and USE PHP DOM parser to parse and extract the content from it.
2. You can use PHP Simple DOM Library, check here : http://simplehtmldom.sourceforge.net
It has ready made functions and you won't need to use CURL much here.
I hope you get an idea.
Try some code, show us here and we will guide more on this...

Multiple Blog Feed [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I hope you're having an awesome day.
Today I wanted to implement a blog on my site, write it on bloggr and when I post it, feed it to mysite.com/index.html What would I need to be able to accomplish this! Help would be greatly appreciated!
I was searching around blogger and ended up in a configuration of it,
1st. I get asked for my domain.
Then I have to replace the CNAMES...
-the blog just redirects to my domain with bloggr style...I want the blog to be displayed on one blog.mydomain.com/post-youre-watching
I also want a div with the feed of the last 3 entries(despite the author)...How can I accomplish this? You guys know anywhere where I could find information on how to do this? If so, what information(or language) do I need to learn?
If you want to present the content on your site (rather then making your hostname point to Blogger) then you'll need to actually put it on your site.
The simplest way would be to periodically pull the data from the Atom or RSS feed hosted by Blogger and store the content in a database on your server.
You can then query it with your own server side code to get whichever combinations of data you desire.

Categories