I'm using PDO, I can't use the MySQL function.
How to get the first piece of data and 4th 7th data.
Reply to discussion (solution)
What is the table structure and what is the sort basis?
Sort of no basis I can't write with limit.
Are you getting 第一、四、七条 every time? Or next time it may be 第二、五、六条 data, if the data is always the few, directly with the ID as a condition can be, if you are always updated, it is recommended that you write the survival of SQL
Not 1 4 7 10 13 16 19 22 25 How to use the ID to make a conditional ah, every time I delete a data ID, it's messy.
$t = Array (1, 4, 7); The sequence number to get
$ar = $db->query ($sql)->fetchall (PDO::FETCH_ASSOC); Executes the query and saves the result to the array
foreach ($t as $k) $r [] = $ar [$k-1]; Extract the required records
The code upstairs is so esoteric.
Can't you use limit?
If there is no complete rule, it is difficult to determine the data you want to obtain, you want to get that data, what is the condition, or notify the external factors to get the ID of the record you want ....
$t = Array (1, 4, 7); The sequence number to get
$ar = $db->query ($sql)->fetchall (PDO::FETCH_ASSOC); Executes the query and saves the result to the array
foreach ($t as $k) $r [] = $ar [$k-1]; Extract the required records
You don't even have to choose a database table?
What is the table structure and what is the sort basis?
Don't you have a choice when you instantiate PDO?
Query 7 records from the database, save in the array, and then take the specified number of bars you want (the array subscript is starting from 0)
$t = Array (1, 4, 7); The sequence number to get
$ar = $db->query ($sql)->fetchall (PDO::FETCH_ASSOC); Executes the query and saves the result to the array
foreach ($t as $k) $r [] = $ar [$k-1]; Extract the required records
The code upstairs is so esoteric, your needs are more obscure.
Is PDO really that good? I didn't use it.
Query 7 records from the database, save in the array, and then take the specified number of bars you want (the array subscript is starting from 0)
Reference 5 Floor Xuzuning's reply: $t = Array (1, 4, 7); The sequence number to get
$ar = $db->query ($sql)->fetchall (PDO::FETCH_ASSOC); Executes the query and saves the result to the array
foreach ($t as $k) $ ...
Reference 6 Floor u010209578 's reply: The code upstairs is so esoteric, your needs are more obscure.
How can I not feel the use of .... I don't know where to begin ...
Reference 13 Floor xuzuning reply: Reference 6 floor u010209578 's reply: The code upstairs is so esoteric, your needs are more obscure.
How can I not feel the use of .... I don't know where to begin ...
Suggestion: Read more PHP Manuals
If you don't understand, you can ask
If there's nothing you can do, it's not a school.
Is PDO really that good? I'm not used to it. Haha PDO is the fastest to execute MySQL statement today haha
Query 7 records from the database, save in the array, and then take the specified number of bars you want (the array subscript is starting from 0)
Reference 5 Floor Xuzuning's reply: $t = Array (1, 4, 7); The sequence number to get
$ar = $db->query ($sql)->fetchall (PDO::FETCH_ASSOC); Executes the query and saves the result to the 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", "");
$sql 1= "SELECT * from www";
$rs = Query ($sql 1), $pdo
while ($row = Fetch () $rs)
{
Echo '. $row [id]. ";
}
?>
I used to be like this.