Ultradev example tutorial: 5 Make a relatively simple website backend (2)
Author:Eve Cole
Update Time:2009-05-26 16:34:27
First create a homepage, which is the 5 latest updated news records. Using the Ultradev record display function we learned, you can easily create a page as shown below:
How to display the latest 5 updated records? Let's take a look at the dialog box for creating a recordset:
If we follow the general method of creating a record set, the content displayed in the SQL column in the above picture will be:
SELECT ID, title, insert_time (We only need to display the title and recording time of the news, and the news content does not need to be realistic, so there is no need to select the content field)
FROM article
We modified her to look like above. top 5 means that I only select 5 records, and ORDER BY ID DESC means that the records are selected from the back to the front according to the ID field (DESC means descending order, and the ID field is automatically numbered, that is, the default is ascending order) , this realizes our idea of going to the 5 latest updated records.
When adding the repeat region behavior of server behaviors, choose to display all records (because we only fetched 5 records). Careful friends must have thought at this time, oh, I can also realize the idea of how many records I want to display by displaying how many records on one page here! Yes, that's right, you can choose to display 5 records per page, which can also achieve the effect we want to achieve---but don't forget, ORDER BY ID DESC is essential^_^
Then we select {RECORDSET1.title} in the title cell and add a server behavior----Go To Detail Page to it, as shown in the figure:
Our purpose is to pass an ID value to the detail.asp page so that it can correctly retrieve the records we want. After completing this, add a More connection pointing to more.asp to display more news records.
The page effect is as shown in the figure:
In the more.asp page, we only need to simply modify the home page just now to use it. Open the dialog box for creating a record set, remove the top 5 we added (this will remove all the records in the database table), then modify the number of items displayed on each page of the repeat region to 10, then delete the more connection, and then insert Insert -> Live Objects -> Recordset Nagaviation Bar, so that we can turn pages to display news. The page is as shown:
Next we will create the news detail page (ie detail.asp). As we mentioned above, the most important thing we do in the detail.asp page is to get the value passed from the previous page, here it is ID=x. As shown in the picture:
Just come down, make some tables, and drag the items in the created record set one by one, as shown in the figure:
At this point, our front-end page is completed, and next we need to create the back-end management page.
Originally, the correct sequence should be to create the backend management page first, and only then create the frontend page when data can be added, deleted, and edited correctly. Because after all, the front-end page is just for data display. If you can't even add data, it will be useless no matter how beautiful your front-end page is. And if you make the back-end management page, you don't have to pursue the beauty of the page so much. If you make a mistake, you need to revise it again. It is also fast, unlike the front desk, where once the page is designed, it is very laborious to change it (although Ultradev has made this task relatively simple, it is still prone to problems). However, because our pages are relatively simple and the data structure is simple and error-free, we will not emphasize this point. But friends, when doing it in the future, it is better to do it in the order of backstage -> frontstage.
Chapter 5: Make a relatively simple website backend (2)
The background management page can be divided into three parts:
Data addition
Data editing and deletion
Login verification
Let's start with adding data. From the previous study, we know that it is extremely simple to create a data adding page in Ultradev, just Insert -> Live Objects -> Recordset Insertion Form. As shown in the picture, it is a page for adding news. Adding an administrator user is similar, so I won’t go into details:
After creation is completed, as shown in the figure:
This is the page for adding new users:
Open the browser and see the effect:
But here comes our problem. After you add late data, open the corresponding detailed information page from the home page. At this time, you will see that the data that was clearly segmented when you just added it is now crowded into a ball. The original segments are gone!
All netizens who use UltraDev software must have encountered the phenomenon that the text on the asp page is squeezed into a ball after being exported from the database, and the spaces and line breaks originally entered are gone. Because the spaces and line breaks in the database are not processed at all in the asp statement. Of course, netizens who have learned asp programming can add their own code to convert spaces and line breaks in the database into html codes, or they can first convert spaces and line breaks into html codes when text is submitted into the database and then output. But no matter which method is used, it is undoubtedly like a nightmare for netizens who have not learned asp. Even if you learn to convert, you still need to manually modify the source code in each asp page, which is time-consuming and laborious. For a long time, there has been no very convenient solution.
what to do? Haha, don’t worry, here we need to use the plug-in function we talked about before.
Here we are going to use a plug-in---Spdesign format to help us implement a function (click here to download the plug-in).
Next, I recommend to you an UltraDev plug-in that can solve this problem: The method of use is very simple. You only need to apply the plug-in's command after selecting the dynamic data to complete the formatting of spaces and line breaks.
As shown in the figure after plug-in installation
How to apply this plug-in? It’s very simple. See the picture below. Is it clear at a glance? *_"
After applying the plug-in, check our page again, ah, is it the effect you want?
Adding a record page is relatively simple. If you carefully read what we have said before and do some exercises, I believe you will be able to do it soon. Okay, next, we are going to talk about editing and deleting records. We have analyzed it before. To edit and delete records, we actually need to pass a value from one page to another page, and then use the other page to extract the corresponding and unique record based on the passed value to apply editing. , the act of deletion. Therefore, we first need to create a page for passing values. This page is very simple. It is actually a data display page, but two connections are added: Modify, delete, select these two connections, and apply the Go To Detail Page behavior in server bahaviors: change_article.asp and del_article.asp respectively. (Here we take editing and deleting news as an example, and user management is the same)
The final page is shown in the figure:
Display effect in browser: