i have some trouble with mysql query. I just figure out, how to get a row position in mysql with condition. Let me explain what i want to achieve.
I have a table gallery and it look like this :
id_gallery source status post
1 img1 last 2012/12/11
5 img2 new 2013/01/01
7 img3 new 2013/01/01
10 img4 last 2012/12/11
22 img5 last 2012/12/14
30 img6 last 2012/12/15
I call the image in page (ex:test1.php) with this query and give the result like this: Here is my query:
select * from gallery where status ='last' order by post DESC
Here is my result :
id_gallery source status post
30 img6 last 2012/12/15
22 img5 last 2012/12/14
10 img4 last 2012/12/11
1 img1 last 2012/12/11
In page gallery i make a query like this :
select * from gallery order by post desc
and give the result like this :
id_gallery source status post
5 img2 new 2013/01/01
7 img3 new 2013/01/01
30 img6 last 2012/12/15
22 img5 last 2012/12/14
1 img1 last 2012/12/11
10 img4 last 2012/12/11
what i want to achieve is something like this :
id_gallery source status post position
5 img2 new 2013/01/01 1
7 img3 new 2013/01/01 2
30 img6 last 2012/12/15 3
22 img5 last 2012/12/14 4
1 img1 last 2012/12/11 5
10 img4 last 2012/12/11 6
And final result would become like this
id_gallery source status post position
30 img6 last 2012/12/15 3
22 img5 last 2012/12/14 4
1 img1 last 2012/12/11 5
10 img4 last 2012/12/11 6
I want to know the right position of the image because in second page(ex:gallery.php), i have a lot of image. And in the first page(test1.php), i just select 5 img with status last and order by post DESC. I want make a link to page gallery.php and i need a correct position. When i get a correct position, i can make a link to each of image and it would be something like this:
<a href='http://localhost/testing/gallery/<?=$result[position]?>.htm'><img src='http://localhost/testing/<?=$result[source]?>.jpg' /></a>
//or in the html would be like this
<a href='http://localhost/testing/gallery/1.htm'><img src='http://localhost/testing/img6.jpg' /></a>
So, if i can get a correct row position, i can make a link that direct to the page correctly.
Can anyone tell me how can i achieve that? I will appreciated your answer,thx before