PHP MYSQL loops to output a single piece of data in sequence
小涛
小涛 2018-03-28 11:47:06
0
3
1667

I want to make a loop to output pictures in sequence. Don’t know how to write this code?

Table structure

          1
##                        id

              img

            key

              date

h1.jpg

1 1522077253
2 h1.jpg
# 1 1522077253
3 h1.jpg
# 2 1522077253
4 h1.jpg
# 2 1522077253
5 h1.jpg
# 1 1522077253
6 h1.jpg
# 2 1522077253
7 h1.jpg
# 1 1522077253
8 h1.jpg
# 3 1522077253
9 h1.jpg
# 3 1522077253
10 h1.jpg
# 1 1522077253
# 11 h1.jpg
# 1 1522077253
12 h1.jpg
# 2 1522077253
13 h1.jpg
# 3 1522077253
14 h1.jpg
# 2 1522077253
15 h1.jpg
# 2 1522077253
16 h1.jpg
# 3 1522077253
17 h1.jpg
# 2 1522077253
18 h1.jpg
# 3 1522077253
19 h1.jpg
# 3 1522077253


For example, the field ID of key=1 is 1,2,5,7,10,11 six fields

I want to output one at a time in order.

The 1st time output id 1 field

The 2nd time output id 2 field

......

The 6th time output id 11 fields

The 7th time output id 1 field

The 8th time output id 2 fields

......

The Nth time Output the next field of id


The loop will continue forever.

No matter how many data with key=1 are inserted in the middle, the loop will continue.



How to write this PHP.

Currently I found a sequential output sql but it is inconvenient to use

select * from tu_pic order by field(id,9,5,6,7,8) limit 1


小涛
小涛

reply all(3)
小涛

I solved it myself. In fact, it is to play every song in an infinite loop

sky

I don’t understand what you want to do


好人二狗

I didn’t do what you did, this should be an infinite loop,

$sql = 'select * from tu_pic order by id desc limit 1'

for ($i=0; ;$i++) {

$reult = mysql_query($sql);

var_dump(mysql_fetch_array($result));
}

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template