What is the best way to create a sitemap.xml? [duplicate] - php

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to create a sitemap using PHP & MySQL
So I'm kinda stuck here. I have a website with a pretty big database, that constantly changes. Now I want to help the search engines by supplying a sitemap.xml file. Normally I would use a webservice that would do this, but thats not really possible in this case.
To be honest. I have no clue where to start. How would I go about doing this? Sorry if this is a too basic question, but Google couldn't help me.
Edit: Some more info. DB is currently 1k pages. Want to go up to like 10k. I use Mysql to echo this from my database, and then htaccess to rewrite the URLs.
(PHP's get ID, etc)

You need to install a crawler of doing it like a webservice. The easier way is to write a php script and generate sitemap XML file by yourself.
Write a query to get the links from your database and then iterate over it to create a sitemap.
See this post for example php script How to create a sitemap using PHP & MySQL

Related

User friendly PHP URL [duplicate]

This question already has answers here:
How to create friendly URL in php?
(8 answers)
SEO friendly url using php [duplicate]
(5 answers)
Closed 8 years ago.
I`ve learning development of websites recently and have appreciated quite some concepts in php and mySQL databases. Since I use GET and POST i sometimes end up with such urls: http://seta.com/news.php?articleid=231. how do i make my urls look like this instead: http://seta.com/news/today.
Maybe if one helps me on the subject so that i can search, I don`t even know what I am looking for.
This is called SEO urls or pretty urls. You can use the .htaccess file and regular expressions to rewrite the http://seta.com/news/today url to http://seta.com/news.php?articleid=231 for your program so your program can function without any modifications.
If your program in dynamically creating these links, you will have to update those places so it's outputting the urls as the new pretty urls.
Another way is to direct all urls to news.php and use $_SERVER['REQUEST_URI'] to extract the information from the url. This requires modifications to your code and it will stop working for the ?articleid=123 urls which is useful during development.
By using the GET method to submit data , a question mark followed by the submitted data will be shown like the article id for example : http://seta.com/news.php?articleid=231
<?php $article_id=$_GET['articleid']; ?>
By using the POST method , the url is not going to change :http://seta.com/news
<?php $article_id=$_POST['articleid']; ?>
i hope this is what you looking for
You need to learn some MVC php frameworks then..
CodeIgnitor is good for start
url like http://seta.com/news/today has URI Segments
where news is 1st segment and today is 2nd segment.
IN .htaccess using mode_rewrite you can remove .php from the link and create your links accordingly as you want.

how to get client system info from website? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How can I get system/hardware info via Java?
I'm doing a website with PHP.
one of the functionality need is to get info about the client pc..
Such as ram..graphic card..etc..
why u would say?
I will provide game download on my website..
So i need to provide the client with a way to test if the game will run on his machine
So is there a way i can do that..?
I know theres a website who do something like that: Canyourunit
Need to do something like that..a simple one would be nice
edit: Is there any plugin, library for that?
Thanks :) Best Regards
This is not possible with PHP, JavaScript or anything like that. Even Flash doesn't allow this. You could try to create a Java Applet, i think Java is able to get some system properties. Have a look at this: How can I get system/hardware info via Java?

Php copy website table [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
HTML Scraping in Php
Far from being web developer expert, so sorry in advance if I'm missing something basic:
I need to copy a table into mySql database using PHP; the table resides in a website which I don't own, however I have permission to copy and publish.
Manually when I watch this website in my web-browser I need to click on a link in the main website URL (I can't reach the final destination page link since it changes all time, however the main page link is static and the link to click is also static).
Example to such a content I need to copy from (just an example, this is not the real content):
http://www.flightstats.com/go/FlightStatus/flightStatusByAirport.do?airportCode=JFK&airportQueryType=0
Most people are going to ask what have you tried. Since you mentioned that you don't have much development experience, here are some tips on how to go about it - have to put it as an answer so it is easier to read.
What you're going to need to do is scraping.
Using PHP, you'd use the following functions at the very least
file_get_contents() - this function will read the data in the URL
preg_match_all - use of regular expressions will let you get the data you are looking for. Though some/many people will say that you should go through the DOM.
The data that is returned with preg_match_all can be stored into your MySQL table. Though because the data changes so frequently, you might be better off just scraping that section and storing the entire table as cache (though I do have to say I have no idea what you are trying to do on your site - so I could well be wrong).

Create, Insert, Update or Delete XML using PHP [duplicate]

This question already has answers here:
Add, update and edit an XML file with PHP
(3 answers)
Closed 6 years ago.
So completed my uni stuff using a little help from you fantastic programmers out there and a few all nighters to go as far as I could with manipulating XML data through Javascript. Now I'm done for the summer and my dear old mother has asked me to create her a basic site for her maths tutoring service with info and prices etc... I was thinking as she doesn't need much I would go in for using XML again but this time not restricted on the use of PHP to Create new elements/nodes, update or delete.
I was going to create her a basic booking system with a little admin panel for editing entries etc... As the information doesn't really need to be too secure the use of XML seems to be alright for the purpose.
My question is Does anyone know of any clean basic functions that can be used to this end with XML using PHP ?? In terms of functions I would mean things like Create/Insert, Edit/Update, Delete etc...
Any help or even a site that has a decent tutorial on it would be great as I've gone through youtube and there isn't anything decent or clean and simple.
Thanks in advance!
Well, you can use the DOM methods to create/edit/delete nodes from an XML.
http://us2.php.net/manual/en/book.dom.php
Just curious, why do you want to play with XML, may be the easier choice would be a database as simple as SQLite http://php.net/sqlite.

How to dynamically translate a webpage [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How would you transform a pre-existing web app in a multilingual one?
Best way to internationalize simple PHP website
I'm trying to figure out how to translate all the static texts on my webpage (I'm using PHP). But I'm not really sure what the "correct" way is. This is what I thought of so far, but maybe it's all wrong :D
1.
For every static piece of text on the page, just get the translation with something like "getTranslation("Hello World!") and it will just look up the translation in the database or a file like XML/CSV/PHP with all the translations.
But this seem pretty bad since we will have to query the database or parse the file on every page, everytime it's refreshed/loaded.
2
Everytime a page is loaded I could read from the database/file and store the translations for the current language in an array and get the translations from the array as the page is building, instead querying the database / parsing the file again.
3
Is there some way to read the translations only once and then make it accesible for all pages? The only thing I can think of is php's SESSION but it just seems so wrong to store the translations there.
So what the "most common" or "right" way to do it?
Happy hunting!
Sounds like you need gettext. gettext is widely used and widely supported. I'm pretty sure it's also pretty well optimized.

Categories