Step by step teach you to use Php+mysql to build a website no.2 picture display and page pages

Source: Internet
Author: User

Next to the previous chapter, we now have the first main page of the program, but we will find a few problems, one is the homepage of the picture can not be displayed, and the second is to click Read more ... There is no content after the link

The entrances to the two pages are the contents of the two boxes inside.

Let's take a look at the image display page first;

resize_image.php

We notice that the full URL of this link is: resize_image.php?image=...&max_width=...&max_height=...;

This means that the link has 3 parameters: Image is the name of the picture, max_width and height are respectively the width and height of the picture.

So what are we supposed to do with this page?


This is the complete code for resize_image.php, which compresses or enlarges the original image size according to the width and height of our page input, and then regenerates a new picture for display on the page.


Next we look at the page.php page


page.php


Because clicking on the page is actually the equivalent of opening 3 different types of blog content of the detailed page, so we definitely need to go to the database inside the select operation.

In the previous blog has been explained, we only need to change the middle of the display, so in line 10th and 47th, we respectively introduced header.php and footer.php, the middle of the content we will be displayed through the database query.

When we show page pages, there may be times when a user clicks on a story, when the argument contains stories, passing in the ID, or maybe just a page field for a certain class, so there's not one in the argument, Let's decide how to write our select.

But anyway, the last thing we get is this table structure:


Let's review the establishment process of the stories table:


Note that the ID field is not just primary key, but it is also the Auto_increment property, in MySQL, Auto_increment is the self-increment field, each time the data is inserted, the maximum value of the current sequence is automatically queried, and then added 1,



Everyone to see my stories table in all the content, 1-7 are we through the manual insert into the textbook, and then we will find that the next 11, and there is no 8,9 and 10, because I was in the development process of the insertion and deletion, I took the ID 8,9,10 record deleted, So it is not shown in the table, but even if your table has the largest ID of 7, his record will be inserted into 11, that is, the self-increment sequence is independent of the current table, and the Oracle's self-increment sequence, but I am not quite sure what the difference between the self-increment sequence in MySQL and Oracle.

The self-increment sequence in Oracle is established by:

CREATE SEQUENCE "seq_id" MINVALUE 1 MAXVALUE 999999999999 INCREMENT by 1 START with 1 CACHE noorder nocycle;

and then use it directly insert .... VALUES (Seq_id.nextval) are equivalent to inserting the next value of the next self-increment sequence, so there can be several self-increment sequences in Oracle. But it's not clear what the self-increment sequence is in MySQL, and visual inspection is only a common self-increment sequence.


Okay, let's get back to the point, in the while loop, we can see that each story is made up of 4 parts,

27 Lines:

Show the headline of each story,

29-35 lines:

According to the stored picture name to display the image, the method used is still the resize_image.php we mentioned above

36-41 lines:

Here we need to use the new function in db_fns.php:

Add the following function into the db_fns.php, this function is very simple, that is, the current Sotry writer information to find.


Then show the time when the article was modified:

Here in the database is stored in the form of 10-bit timestamp, display the time according to the format to do a conversion is good:

Date (' M D, H:i ', $story [' Modified ']);

44 Rows

Displays the subject content of the story.

OK, so we can see the picture on the interface, and then we can click on most of the buttons on the main screen.

In the next section, we'll do the user login, then add the article and so on.

Step by step teach you to use Php+mysql to build a website no.2 picture display and page pages

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.