Step by step, you can use PHP + MySql to build the No. 2 Image Display and Page of the website,
Next, let's look at the previous chapter. Our current program has the first homepage, but we will find several problems. One is that the pictures on the homepage cannot be displayed, second, Click read more... NO content in the subsequent Link
The portals of these two pages are the content in the two boxes.
Let's first look at the page shown in the image;
Resize_image.php
We noticed that the complete URL of this link is:Resize_image.php? Image =... & max_width =... & max_height =...;
That is to say, this link has3Parameter: image is the image name. max_width and height correspond to the image width and height.
What should we do on this page?
This is the complete code of resize_image.php. compress or enlarge the original image size based on the width and height entered on the page, and then generate a new image for display on the page.
Next let's take a look at the page. php page.
Page. php
Because clicking the page is equivalent to opening three detailed pages of different types of blog content, we certainly need to perform the select Operation in the database.
As described in the previous blog, we only need to change the display content in the middle. Therefore, we introduced headers in rows 10th and 47th. php and footer. php, the content in the middle is displayed after being queried by the database.
When we display the page, sometimes the user clicks a story. In this case, the story parameter is included and the story id is passed in. Or, a certain type of page field is only used, therefore, we can determine how to write the select statement based on whether there is any story in the parameter.
However, in any case, we finally get the following table structure:
Let's review the creation process of the stories table:
Note that the id field is not only the primary key, but also the auto_increment attribute. in MySQL, auto_increment is an auto-increment field. Each time data is inserted, the maximum value of the current sequence is automatically queried, then add 1,
Let's look at all the contents in my stories table. We inserted them through the textbooks manually. Then we will find that the next step is 11, but there are not 8, 9, and 10, the reason is that I have performed the insert and delete operations during the development process. I deleted the records with IDs 8, 9, and 10, so they are not shown in the table, however, even if the maximum id in your table is 7 at this time, his records will be inserted into 11, that is, the auto-increment sequence is independent of the current table, the auto-incrementing sequence in mysql is the same as that in oracle, but I am not sure about the differences between the auto-incrementing sequence in mysql and oracle.
The method for creating auto-incrementing sequence in Oracle is as follows:
CREATE SEQUENCE "SEQ_ID" MINVALUE 1 MAXVALUE 999999999999 INCREMENT BY 1 START WITH 1 CACHE 10 NOORDER NOCYCLE;
Then, insert .... values (seq_id.nextval) is equivalent to inserting the next value of the next auto-incrementing sequence. Therefore, there can be several auto-incrementing sequences in oracle, but it is not clear what the auto-incrementing sequence in MySQL is like. The visual test only has one common auto-incrementing sequence.
Now let's get back to the question. In the while LOOP, we can see that each story is composed of four parts,
27 rows:
Displays the headline of each story,
Line 29-35:
The image is displayed based on the stored picture name. The method used is still resize_image.php.
Lines 36-41:
Here we need to use the new function in db_fns.php:
Add the following function to db_fns.php. This function is very simple, that is, to find the current sotry writer information.
Then display the article modification time:
The database stores 10 bits.TimestampThe format is converted according to the format when it is displayed:
date('M d, H: i', $story['modified']);
44 rows
Displays the topic content of a story.
Okay, so that we can see the image on the interface, and then click most of the buttons on the main interface.
In the next section, we will log on as a user and add new articles.