Mysql Acquisition problems

Source: Internet
Author: User
Tags mysql functions
I am using pdo and cannot use mysql functions.

How to obtain the first and 4th pieces of data.


Reply to discussion (solution)

What is the table structure and the basis for sorting?

I can't write the sorting based on limit ..

Do I get the first, fourth, and seventh entries each time? Next time, it may be the second, fifth, and sixth pieces of data. if the obtained data will always be those pieces of data, you can directly use the id as the condition. if your data is updated at any time, we recommend that you write a usable SQL statement.

Not 1 4 7 10 13 16 19 22 25 How do I use ID as a condition? every time I delete a data ID, it's messy.

$ T = array (1, 4, 7); // The sequence number to be obtained
$ Ar = $ db-> query ($ SQL)-> fetchall (PDO: FETCH_ASSOC); // execute the query and save the result to an array.
Foreach ($ t as $ k) $ r [] = $ ar [$ k-1]; // extract the required record

The upstairs code is profound.

Cannot I use limit?

If there are no complete rules, it is difficult to determine the data you want to obtain. What are the conditions for obtaining the data, or notify external factors to get the id of the record you want ....

$ T = array (1, 4, 7); // The sequence number to be obtained
$ Ar = $ db-> query ($ SQL)-> fetchall (PDO: FETCH_ASSOC); // execute the query and save the result to an array.
Foreach ($ t as $ k) $ r [] = $ ar [$ k-1]; // extract the required record


Even database tables do not need to be selected?

What is the table structure and the basis for sorting?

Why didn't you choose to instantiate PDO?

Query 7 records from the database, store them in the array, and then take the specified number of records you want (the array subscript starts from 0)

$ T = array (1, 4, 7); // The sequence number to be obtained
$ Ar = $ db-> query ($ SQL)-> fetchall (PDO: FETCH_ASSOC); // execute the query and save the result to an array.
Foreach ($ t as $ k) $ r [] = $ ar [$ k-1]; // extract the required record

The upstairs code is so esoteric your needs are more concealed

Is PDO really so useful? I have never used it.

Query 7 records from the database, store them in the array, and then take the specified number of records you want (the array subscript starts from 0)

Reference the reply of xuzuning on the 5th floor: $ t = array (1, 4, 7); // The sequence number to be obtained
$ Ar = $ db-> query ($ SQL)-> fetchall (PDO: FETCH_ASSOC); // execute the query and save the result to an array.
Foreach ($ t as $ k) $ ......

Reference the reply of u010209578 on the 6 th floor: the code on the upstairs is so esoteric that your requirements are more concealed.

How can I feel that I can't use it .... I don't know where to start ......

Reference the reply from xuzuning on the 13th floor: reference the reply from u010209578 on the 6th floor: the code on the upstairs is Esoteric. your requirements are more obscure.

How can I feel that I can't use it .... I don't know where to start ......
Suggestion: read the php Manual.

If you don't understand, you can ask
I can't do anything else. it's not a school.

Is PDO really so useful? I have never used it yet. haha, PDO is the fastest way to execute mysql statements. haha

Query 7 records from the database, store them in the array, and then take the specified number of records you want (the array subscript starts from 0)

Reference the reply of xuzuning on the 5th floor: $ t = array (1, 4, 7); // The sequence number to be obtained
$ Ar = $ db-> query ($ SQL)-> fetchall (PDO: FETCH_ASSOC); // execute the query and save the result to an array.
Foreach ($ t as $ k) $ ......

I really don't... $ Row [field name] I used to output it like this.

$ Pdo = new PDO ("mysql: host = localhost; dbname = uzhan", "root ","");
$ Sql1 = "select * from www ";
$ Rs = $ pdo-> query ($ sql1 );
While ($ row = $ rs-> fetch ())

{
Echo'

'. $ Row [id].'

';

}
?>
I used to do this.
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.