When used to display database data, generally use the cyclic body to do, the common method has two statements, and let's talk about their usage in different situations.
Let's introduce:
While () statement is that all data can be displayed, and it is especially convenient to do not know the number of cycles, and the FOR () statement, which can output data from the beginning to the specified position to the specified position, the output display is displayed. It is used when data is available. Let's take a look at the programming instance:
Let's build a database to stand: The database name is: MyDB table name is: TBL.
With the following statement: Create Table Tal (IDX INT (3), URL Char (100), Freetext CHAR (100))
Several data can be inserted into the log table with a phpMyAdmin tool.
Programming start:
$ ID = mysql_connect ("localhost") or Die ("Unable to create a database link"); #Link Database
$ Result = mysql_db_query ("MyDB", "SELECT * FROM TBL", $ ID); # query results and stored in variables
$ ROWS = mysql_num_rows ($ result); # 得 出 数据 表 表 表 表 数 数 个 个;
Echo "