Display MySQL columns into Rows- phpmyAdmin

SELECT r0.unit_model, r0.tab_type, r1.title_en AS “H1_EN”, r2.title_en AS “H2_EN”, r3.title_en AS “H3_EN” FROM (SELECT DISTINCT unit_model, title_en ,tab_type FROM unit_models_copy WHERE  tab_type=’hl’ AND (unit_model=’5051′ OR unit_model=’5052′ OR unit_model=’5064′)   ) r0 LEFT JOIN unit_models_copy r1 ON r1.unit_model = r0.unit_model   AND r1.tab_type=’hl’ AND r1.`ranking`=’1′ LEFT JOIN unit_models_copy r2 ON r2.unit_model = r0.unit_model  AND r2.tab_type=’hl’ AND r2.`ranking`=’2′ […]

Read More

Facebook Page feed on website-PHP

Following is the code to display your facebook page feed on your website using PHP, cURL : It would display top 5 posts on your Facebook page as the limit which I gave here 5. All you would need is your PAGE-ID, APP-ID, APP-SECRET $page_name = yourpage_name; // Example: http://facebook.com/{PAGE_NAME} $page_id = yourpageid; // can get […]

Read More

jQuery Navigation/ Promotional Banner- Cookie

Following is the code for a  Promotional banner which is supposed to be seen on all the pages of the website. The banner would have the following functionalities: It should be displayed above the header. It has a close button. If anyone closes the banner it should not be displayed again on any page for […]

Read More

jQuery Navigation/ Promotional Banner- Session

Following is the code for a  Promotional banner which is supposed to be seen on all the pages of the website. The banner would have the following functionalities: It should be displayed above the header. It has a close button. If anyone closes the banner it should not be displayed again on any page for […]

Read More

Update if record already exist else insert-MySQL

I am uploading an excel file into the database table, What I want is, If any record from excel sheet already exists into the table then update that record with the latest data which is available on the sheet. How to do that? Well, It is pretty simple Following is the syntax to perform that […]

Read More

Image Map On background Image-Responsive

Following is the code to use mapping in the responsive background image.  Code written here is for the rectangular image. First half[50%] of the image is linked to one URL, and another 50%[half] image is linked to another URL. /* HTML code for imap */ <div id=”demo”>  <a id=”link1″ title=”link1″ href=”#”></a>  <a id=”link2″ title=”link2″ href=”#”></a> </div> […]

Read More

Mysql Display 2 columns output into one

I have 2 columns(A & B), what I want to do is to display output into a single column. INPUT: A B 12 1 134 12 145 554 OUTPUT: A 12 134 145 1 12 554   To obtain this output we need to use the  ‘UNION’  operator.   So the query would go like: […]

Read More

MySQL calculate distance between two latitude/longitude coordinates

–Returns the distance in kilometers, assuming an earth radius of 6,371 km. SELECT D.idx,D.name,( 6371 * ACOS( COS( RADIANS(C.latitude) ) * COS( RADIANS( D.latitude ) ) * COS( RADIANS( D.longitude ) – RADIANS(C.longitude) ) + SIN( RADIANS(C.latitude) ) * SIN( RADIANS( D.latitude ) ) ) ) AS kms FROM dealers D,cities C GROUP BY D.idx […]

Read More