ZENCART php randomly calls the title and content of the database
Using the program to work with SEO is a good idea. Using the PHP code, you can use the articles and standard content in the data library on your phone, when refreshing the front-end interface, different content is displayed. If the spider can capture different contents every time it crawls, is the effect good.
So I just copied onePHP appletsTo realize this function. The principle is as follows:
First, I create a table named randcontent in the Data Warehouse. Then, the table contains three fields: post_id, post_title, post_content, then, use the phone number to retrieve a post_id, and then use the post_id to retrieve the content of post_title and post_content.
$ Dbh = @ mysql_connect ("localhost", "root ","");
If (! $ Dbh) {die ("error ");}
@ Mysql_select_db ("phptest", $ dbh );
$ Posttotal = "select count (post_id) as total FROM randcontent WHERE post_id is not null"; // SQL statement, which reads the number of rows in the table
$ Query1 = mysql_query ($ posttotal, $ dbh); // begin an SQL statement.
$ Res = mysql_fetch_array ($ query1); // generate a Data Group
$ Count = $ res ['Total']; // change the memory value to $ count
$ Randcount = rand (1, $ count); // gets a number between ID1 and the maximum number of articles on the fly. This number is the ID of this article.
$ Getpost = "SELECT post_title, post_content FROM randcontent WHERE post_id = $ randcount ";
$ Query2 = mysql_query ($ getpost, $ dbh );
$ Res2 = mysql_fetch_array ($ query2); // generate a Data Group
$ Post_title = $ res2 ['Post _ title']; // obtain the subject
$ Post_content = $ res2 ['Post _ content']; // retrieve the content
Echo '<strong>'. $ post_title. '</strong> <br/>'. $ post_content; // specify the subject and content.