php - how to get image path of highest vote -
my table schema follows:
id || image1 || image2 || image1vote || image2vote || uid 1 abc.jpb adc.jpg 50 40 12 2 bc.jpb dc.jpg 20 70 13 3 kjc.jpb ydc.jpg 20 10 10 4 pjc.jpb mkc.jpg 80 60 10
i using mysql phpmyadmin back-end.
from front-end uploading 2 images storing in database. both images saving votes separately. votes image1
stored in column image1vote
, while votes image2
stored in column image2vote
.
my problem following: want image path of image has votes. so, if image1 has more votes image2, want value of image1
, other way around.
for example: in first row, want value of image1
since value in image1vote
bigger value in image2vote
. in second row, want value of image2
.
i haven't tested it, if understood question correctly, should this:
select if(image1vote >= image2vote, image1, image2) path, greatest(image1vote, image2vote) votes imagetable
Comments
Post a Comment