Posts

Showing posts from February, 2015

Performing Inner Join for Multiple Columns in the Same Table

Performing Inner Join for Multiple Columns in the Same Table tbColors color_code , color_name 1 , 'blue' 2 , 'green' 3 , 'yellow' 4 , 'red' tbAnswers answer_id , favorite_color , least_favorite_color , color_im_allergic_to 1 , 1 , 2 3 2 , 3 , 1 4 3 , 1 , 1 2 4 , 2 , 3 4 This seems like the way to go: SELECT A . answer_id , C1 . color_name AS favorite_color_name , C2 . color_name AS least_favorite_color_name , C3 . color_name AS color_im_allergic_to_name FROM tbAnswers AS A INNER JOIN tbColors AS C1 ON A . favorite_color = C1 . color_code INNER JOIN tbColors AS C2 ON A . least_favorite_color =...

Tutorial: Using PHP’s JSON encode and decode functions to handle data sent to and from your app

Tutorial: Using PHP’s JSON encode and decode functions to handle data sent to and from your app JSON  makes dealing with data in your app exceptionally easy and manageable. The best part about  JSON  is you can look at it and understand it. It’s not like the confusing spaghetti DOM that you get with XML, it’s a lean minimal representation of your data. If you’re dealing with chunks of data in your app, you want to be using  JSON . So while your app will happily eat up all the  JSON  you can throw at it, you still need to make it in the first place – and/or have a server side app that is capable of reading it. If, like me, you use PHP to handle things on a server then things are pretty straightforward. You can use PHP’s  json_encode  and  json_decode  functions. Encode will take your arrays, or objects, and create a  JSON  string of your data. While decode will take a  JSON  string, sent from your app, and turn...