Displaying Custom Ads in Mobile Apps (API)

Views: 54

We use ORDER BY RAND() in php to randomize the order of datas displaying, which is mainly used at Ads / Images change on every time page loads.

Sample Code :

"select * from tablename where status = 'Enable' ORDER BY RAND() LIMIT 1"

Output displayed on first time, the page loads

{
    "id": "5",
    "custom_ad_name": "First Cry Ad",
    "custom_ad_img": "firstcry-offer-ad.jpg",
    "custom_ad_url": "https://www.firstcry.com",
    "status": "Enable"
}

Output displayed on second time, the page loads

{
    "id": "1",
    "custom_ad_name": "Flipkart Ad",
    "custom_ad_img": "flipkart-offers-ad.jpg",
    "custom_ad_url": "https://www.flipkart.com",
    "status": "Enable"
}

Author:

Leave a Reply