Twitter | Search | |
Pieter Levels ✨
Starting on the website for ✈ now, I will log the full development right here in this thread 👇
Reply Retweet Like More
Pieter Levels ✨ Dec 3
Replying to @levelsio
I always start like this in my code editor, just raw HTML code, no styling (yet), to get the basic functionality down
Reply Retweet Like
Pieter Levels ✨ Dec 3
Replying to @kiwicom247
I'm also adding a BOOK FLIGHT option, which gets the flights from an API like and rates each flight by service, comfort, on-time and safety
Reply Retweet Like
flowen Dec 3
Replying to @levelsio
What is it about?
Reply Retweet Like
Pieter Levels ✨ Dec 3
Replying to @flowen_nl
A live index of airlines compared by safety, on-timeness and service quality
Reply Retweet Like
Pieter Levels ✨ Dec 3
Replying to @levelsio
Now I need to get the data from the Google sheet I made into my SQLite database, for that I use this script (I took it from Nomad List's code), it goes over the sheet and inserts all data into the db
Reply Retweet Like
Pieter Levels ✨ Dec 3
Replying to @levelsio
I've added database-style column names in the sheet, these have to correspond with the SQLite table structure I'm gonna make now...
Reply Retweet Like
Pieter Levels ✨ Dec 3
Replying to @levelsio
I use phpLiteAdmin, a light-weight editor for SQLite databases that runs on PHP. Let's make airlines.db!
Reply Retweet Like
Pieter Levels ✨ Dec 3
Replying to @levelsio
Inside airlines.db I make the table airlines (I always use one table per .db file to keep it simple)
Reply Retweet Like
Pieter Levels ✨ Dec 3
Replying to @levelsio
Here's my airlines table structure, I can always add/edit later so it doesn't have to be perfect immediately. I use "epoch" as a seconds since 1970-01-01 (epoch) field to save when it's last updated
Reply Retweet Like
flowen Dec 3
Replying to @levelsio
Sweet! Where do you scrape the data from?
Reply Retweet Like
James Butler Dec 3
Replying to @levelsio
Was this information all crowd-sourced, like with NomadList?
Reply Retweet Like
Pieter Levels ✨ Dec 3
Replying to @jamesbtlr
Nope, it was added manually in an openly viewable sheet though
Reply Retweet Like
Pieter Levels ✨ Dec 3
Replying to @levelsio
Here's my airlines table structure, I can always add/edit later so it doesn't have to be perfect immediately. I use "epoch" as a seconds since 1970-01-01 (epoch) field to save when it's last updated
Reply Retweet Like
Pieter Levels ✨ Dec 3
Replying to @levelsio
Here's the code which puts it into SQLite, it's a bit ugly, but makes sure every value I want goes in there. I can make it dynamic later, but for now this is easiest to make.
Reply Retweet Like
Pieter Levels ✨ Dec 3
Replying to @levelsio
Yay, it worked 😙 the spreadsheet data is now in a SQLite db called airlines.db, now I will try access it from the site...
Reply Retweet Like
Pieter Levels ✨ Dec 3
Replying to @levelsio
To test if it worked I load the DB on /index.php and do echo json_encode($airlines); This prints the data into JSON, so I can see if it's readable by my site. I can now start putting in a <table>
Reply Retweet Like
Pieter Levels ✨ Dec 3
Replying to @levelsio
Now I put it in a foreach($airlines as $airline) loop inside <table> HTML, here's how it looks if you open it
Reply Retweet Like
Pieter Levels ✨ Dec 3
Replying to @Namecheap
I made all this on my laptop, so now I want to deploy it to so you can see it too. I go to to DNS and add my server's IP as an A/AA record. It was a URL redirect before to the Google spreadsheet, that ends now.
Reply Retweet Like
James Butler Dec 3
Replying to @levelsio
Cool! Thanks for sharing this process, Pieter. Love the transparency
Reply Retweet Like